How to make users pay for transactions with tokens

Hello. So I implemented meta transactions with the help of Relayer and Autotask and @spalladino :slight_smile: Everything works fine and loving it!

However I have one problem. Since I'm paying for the gas now, I want users to pay for tx using a specific ERC20 token. I know how to transfer the token from the user to whatever account I want but then the transfer is another transaction which requires the user to sign. This will make users sign transactions twice (one for the orginal tx and one for the ERC20 payment).

I'm looking for a way to make the user sign only once. Any ideas please?

@spalladino please any ideas?

Hey @isoteriksoftware! The usual flow for having your users pay you in erc20 for relaying their txs is having a Forwarder that, in addition to verifying the user's signature and forwarding the call, also executes a transferFrom on an erc20 to take some of the user's funds and move them to whoever is paying for the gas (aka tx.origin).

Note that, for this to work, you'll first need your user to grant an erc20 approval to your forwarder, so it can call transferFrom. This initial tx does require the user to pay for gas, since it needs to come from the user's address, unless you are working with a token that supports ERC20Permit or a similar method (such as DAI or USDC).

Hope this helps!

1 Like