As we know that each transaction on EOS needs the amount of EOS tokens fee for CPU/NET. In which case of our business cases, we want to take care of the fee for all users. That’s meant the user does not care about the transaction fee each time they go to our dApp and make transactions. Today, I give you a guide to performing it by following steps:
- Make an action which is called
payforcpunet
(or whatever name you want) on your smart contract.
[[eosio::action]] void payforcpunet(const name& recipient) { require_auth(get_self()); }
- After you deployed your smart contract. You have to add a new
payforcpunet
permission for your EOS account (The EOS account you used for deploying the smart contract).

- Almost done, at your backend side, each time you want to do your main action, you should include payforcpunet action on it (that’s mean we are using multiple actions on a transaction).
const actionParams = { actions: [ { account: `${your EOS account}`, name: 'payforcpunet', authorization: [{ actor: `${your EOS account}}`, permission: `payforcpunet` }], data: {recipient: actor} }, { account: `${your user account}`, name: 'transfer', authorization: [{ actor: `${your user account}`, permission: 'active' }], data: { from: `${your user account}`, to: `${your EOS account}}`, quantity: "1.0000 TEST", memo: "Covering CPU and NET for this transaction" } }, { account: `${your user account}`, name: `${action name}, authorization: [{ actor: `${your user account}`, permission: active }], data : {...your action data here...} } ] await this.eos.transact( actionParams, { blocksBehind: 3, expireSeconds: 60 })
Well done!
Enjoy your coding!