Hi,
Yesterday, during Native Tokens discussions I was proposing a mechanism to allow a user (transaction sender) to ask
Motivation
One of the fundamental User Experience problems with Blockchain is gas payments. Not only user needs to be aware about his private key / wallet, but also keeping a positive token balance of his account.
Things get even more complicated when a dapp is asking user to pay in a utility token (let’s call them MYU. In that case user usually needs to go to an exchange (which is already a big hurdle for casual Jon), buy AE tokens. Find an exchange which sells MYU tokens, move all this tokens to a wallet and interact with the application.
Removing any step of above increases the user experience exponentially.
Goal
Update the Transaction protocol to allow 3rd party smart contract to pay for a gas.
Current solutions
Today, this is solved
This proposal
Add a new optional field to the transaction: tx_pay_by: address (must be a contract address).
When an aeternity node is processing transaction and will see such field, it will try to call tx_pay_for function of a contract at tx_pay_by address:
contract TxPayFor =
@param caller Transaction originator
@param tx_type Type of transaction (native token, contract call, new contract ...)
@param call Contract function call.
entrypoint tx_pay_for(caller: address, tx_type: variant: TxType, call: string) : bool
The function should return true if it accept that the tx_pay_by contract will pay for the gas.
Otherwise the caller will be charged for the gas.
We should think what’s the best tx_pay_for interface (declaration). Maybe it should be more generic and take a serialized call details?
Example
Let’s consider dapp G which is a game. It provides a contract G_Pay which implements TxPayFor interface. tx_pay_for can do the following checks:
- Check if
calleris registered dapp user - Check if
calleris calling one of the allowedGcontracts - Check if
callersubscription is valid and he topped up enough money to theGdapp.
If all good, G_Pay will pay for the caller transaction and update his “subscription balance”.

