Lets say we're building an app where users can register/login via their wallets.
They will need a custom ERC-20 or BEP-20 token we've just created for the app (lets call it MyAppToken) by doing a task, such as retouching a photo (for a photo editing app), or playing a music (for a music app). So, they will need to buy the MyAppToken token in an exchange and transfer it to their wallet address registered with the application in order to do certain things.
Let's say someone bought 1000 MyAppToken. He can play 1000 musics with this 1000 MyAppToken where in every single play, a portion of one of his tokens will be transferred to the AppWallet or liquidity pool, and a portion will burn.
How will you manage this? Should we handle all of these in the smart contract or we just need transfer function in our smart contract and simply calling it in our app backend?
How about the transfers? should the backend call the transfer function every single time one of the musics plays or we should call it on a specific amount (10 times or 10 tokens, for ie.)
Who will pay the gas/transfer fees? user or the app?
What's the best approach to design such a do-to-earn or spend-to-getService model?

1 Answer 1


You need different components:

  1. A Smart Contract implementing the ERC-20 standard, in order to mint/burn your tokens. This example, from OpenZeppelin, can work for you.
  2. Token payments verifier component, that can be done off-chain (server side app), or on-chain (Smart Contract) with some limitations but in a more decentralized way.
  3. Token payment executor, for your platform to give rewards (earn), that could require minting function from your ERC-20 token, or to maintain tokens for rewards in a wallet.

When an user pays an amount of tokens to be able to perform an action you must ensure that:

  1. Your platform receives the required payment from that user.
  2. Your user is granted access to the action, he paid for.

Is the action available on-chain (trough a Smart Contract)?

  • If so, you can manage it easily with a Smart Contract.
  • If not, you must develop your function off-chain, reading the blockchain to track if the user's wallet address did the payment, in order to provide access to the service.

You could also manage it in a hybrid way, tracking the payment on-chain with a Smart Contract, and invoking the required API to grant access using an oracle like ChainLink AnyAPI

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.