Transaction Fees in Token

What would be the best approach to build an app that enables users to when they transact using my own token to even have transaction fees deducted using my token

1 Like

You cannot simply pay the fee using your own token, since there is no way for the block proposers to actually know the value of your token. One of the reasons of the existence of transaction fees is to prevent spamming the blockchain. If you could create a fake token and pay fees using this token, you could easily spam the blockchain with as many transactions as you want.

What you can do however, is to provide an TEAL contract account (let’s call it C - see https://developer.algorand.org/docs/features/asc1/stateless/modes/#contract-account) that would pay the fee for your users. This contract may or may not request the user to pay a fee in your own token. At a high level, when a user (with account U) wants to transact with your token, they would make a group of three transactions (aka atomic transfers - https://developer.algorand.org/docs/features/atomic_transfers/):

  1. Send 0.002 Algos from contract account C to account U (authorized by the TEAL script for account C - details below)
  2. Do the normal transaction of x assets from U to the recipient account
  3. (Optional) Make a transaction of fee’ assets from U to C (where fee’ is the fee you require the account U to pay)

The TEAL script for the contract account C would check that it is always in a group of 3 transactions as specified above.

Note: Your contact account C must have enough Algos to pay for all the transactions.

Note 2: Another solution is to have an on-chain exchange allowing to easily exchange your token for Algos (and vice versa). The most basic implementation would be using: https://developer.algorand.org/docs/reference/teal/templates/limit_ordera/