2

I have 2 wallets: wallet A and wallet B where wallet A holds some amount of an ERC20 token.

I would like to be able to transfer some of those ERC20 tokens from wallet A to wallet B in a way that wallet B pays all the gas fees.

I do not want to use the 'approve' function of the ERC20 contract since invoking the 'approve' function involves a gas payment by wallet A (imagin wallet A has 0 ETH, it only holds ERC20).

As I see it wallet A should sign a raw transaction of a smart contract call (calling the 'transfer' function of the ERC20 contract) and wallet B should broadcast it and therefore pay for the gas.

Does this make sense? If wallet B broadcasts transaction which is signed by wallet A, will the msg.sender (inside the contract's 'transfer' function) be recognized as wallet A who singed this transaction?

Assuming this is how it works, how do I create, sign and broadcast a smart contract call using Ethers (preferred with Node.js/Typescript)?

forhas
  • 785
  • 1
  • 7
  • 30
  • This can be achieved if the ERC20 token that you're working with, supports a permit function. – Soham Zemse Oct 22 '21 at 09:49
  • @SohamZemse I wrote that I do not want to use the 'approve' function of the ERC20 contract and explained why. – forhas Oct 22 '21 at 10:34
  • 1
    That's currently not possible in ethereum to make a CALL such that msg.sender is someone else. However there are some EIPs that propose ways to do that. One of them is AUTHCALL (https://eips.ethereum.org/EIPS/eip-3074) – Soham Zemse Oct 22 '21 at 13:14
  • 1
    Btw I meant the "permit" function and not "approve". Wallet A signs a EIP712 permit, and Wallet B broadcasts it. Currently you might use this workaround, until when we get AUTHCALL or something else. – Soham Zemse Oct 22 '21 at 13:16
  • Thanks for clarifying. I can't use EIP712 since ERC20 contracts don't support it. Have you heard of relayers? https://docs.openzeppelin.com/learn/sending-gasless-transactions – forhas Oct 23 '21 at 20:06

0 Answers0