Please describe your proposed solution.
An open source billing server framework that reacts to a queue of tasks to query the blockchain, send assets or confirm payments that can be used by all dApps that involve payment processing.
This billing server would rely on a custom frontend and remote database to form a whole payments-for-resource system. This server would interact with a series of database tables that represent billing task queues, then interact with the blockchain and update the task status for the benefit of a frontend app. The developer community can read the documentation for this server to understand how to create their own MongoDB database, send task objects to it, and ping the database for task status.
The author already has the other components for a full solution in place; namely, a web app and API server that utilizes a working set of user profile data and token gating data in a MongoDB Atlas account. When this proposed project is complete, there will be an instance of this open-source billing server online and in-use with an existing token gating project currently in an alpha phase, and this fully working solution will be presented live and in a recorded demonstration.
Through the use-case app, the author's version of this open-source billing server will be used to facilitate payments for gate-protected content on a third-party website. This app will prove the usefulness of the proposed billing server by allowing users to create token gates for media that require payment in order to pass. Without needing coding skills, NFT projects will be able to dictate that their creative content or livestream be protected behind a specific NFT series, require a particular amount of ADA to pass, or both.
When user payments are detected, this system is capable of performing follow-on tasks aside from querying the blockchain and marking the task as Paid. The task object can include instructions for the billing server to transfer assets from a specific hot wallet on-file to a provided address. The form of payment specified can be any token in the Cardano ecosystem, from ADA to fungibles to NFTs.
This flexibility would allow an app team to use this billing server to not only accept payments for NFTs as a sort of minting service, but to also gamify engagement for holders. An NFT project could, for example, create an app that sends tasks to this billing server in order to facilitate an “evolving” design; a certain NFT is sent to the app and the sender receives either a specific NFT or a random NFT belonging to a specific policy. Another potential use case would be to allow holders to turn in NFTs in exchange for a quantity of fungibles, or even return them for ADA. Yet another use case is as a whitelist - before sending a random NFT, verify the sender holds an NFT from a prior series and also has sent payment.
The primary benefit of this project to the Cardano ecosystem is a potentially significant lowering of development costs for all projects that involve some form of payment processing or token turn-in. By speeding up development for everyone we will surely see more great apps that can get a profitable, revenue-taking app launched in less time and requiring fewer project funds.
The scope of this proposal includes a finite list of task types and related reactions on the billing server:
- Creating internal wallets and associating them with a user identifier
- Detecting payments
- Confirming payment
- Sending tokens
- Generate access to private resources
- Charging and withdrawing
Creating Wallets
This task type asks the billing server to create a wallet and store the keys so that the billing server can make withdrawals at request, or send out assets in the context of NFT purchases, rewards or gamification. This task can specify a user identifier, which is arbitrary to the billing server but can be used by an app that involves user profiles to update that user’s payment status. The author will have an app ready as a live demonstration of this use-case as an app where user accounts have internal wallets associated with them, that they can deposit and withdraw from.
Detecting Payments
Possible conditions for “detect payment” tasks are:
- The receive address (required)
- The sender: From a specific address or anywhere
- The payment quantity
- The payment type: ADA, NFT or FT
- Sending wallet must hold a specific asset
- Sending wallet must hold any NFT in a series
Potential programmable actions include:
- Sending one specific asset
- Sending a random NFT from a specific policy
- Sending a quantity of fungibles
- Generating an authentication token for a resource identifier (OAuth for data)
A payment task object can also include an arbitrary resource ID, so that the billing server can act as a resource server and create an authentication code pointing to that resource. A development team would then create a frontend that can make use of that code to make a one-time fetch of that resource. The author already has an app in place that can demonstrate utilizing auth codes to fetch resource payloads such as videos, games, scripts, or raw data on-page. The author’s app token-gates video content, and with the open source billing server described in this proposal those video token gates will be able to require payment in ADA before streaming.
A developer team could add onto their billing server clone to include server-side actions when payment tasks are completed, such as creating Google Analytics conversion events.
Charging and Withdrawing
This type of task, unlike detecting payments described above, asks the billing server to create a transaction, transferring ADA from a specific hot wallet on file to another address. This can be used by a frontend UI such as a web app or game to send rewards to users if the system is aware of the user’s wallet address. This task type can be used as a token faucet, to send endgame rewards, or to send gift tokens to specific users who do not have to take any particular action.
The task type Withdraw is a request to transfer assets from the wallet belonging to a given user ID to a wallet address provided by the user in the Withdraw function of the demo web app. The billing server in the scope of this proposal is in charge of associating user identifiers with internal wallets. The Charge task type is a request to transfer ADA from a given user’s internal wallet to the billing server’s main revenue wallet. The task specifies the user’s service tier, and the billing server uses its configuration file to determine the amount to charge per service level. In the context of the demo app that leverages this billing server, the failure of a Charge task will demote the user to a Free usage tier which will affect the level at which they can use the app. Success of a Charge task will update the user’s payment status and automatically create a copy task for the next month.
The author will demonstrate a live example of an app utilizing this task type, in the form of a monthly payment subscription service where each user is associated with a hot wallet controlled by the billing server. User statuses will update depending on the success or failure of these transfers, which will alter the ways in which logged-in users can interact with the app.
How does your proposed solution address the challenge and what benefits will this bring to the Cardano ecosystem?
With this solution in place, Cardano project teams can each save themselves a large amount of work re-coding a proprietary solution to this particular component. DApp projects involved in or interested in a form of payment processing can use this billing server in flexible ways to facilitate payments for things of value such as app access, streaming video, wallet verification and other use-cases. Furthermore, this open source billing framework will be put to use in an app that is already live but would make use of this server to allow creators to monetize videos without making an NFT campaign and without needing coding skills.
How do you intend to measure the success of your project?
The proposal scope is for an open source billing server, so our metrics of success will be related to its adoption by the development community.
- Number of Github downloads of the framework
- Number of billing servers online
- Number of successful projects utilizing the framework
- Reported amounts of ADA processed by billing servers
Please describe your plans to share the outputs and results of your project?
We will share the progress and results of this work product on our website as blog updates as well as in partnership with project partners on Twitter and Youtube. We will reach out to projects, create how-to videos, and assist the public at large for working with instances of the billing server to implement their own solutions.