0

I am trying to make a transaction of DAI tokens from user wallet 0xDAIUserWallet to some random token contract say 0xRandomContractAddress. In this scenario I am using the private key of DAI User to sign the transaction as well as to pay gas fee, as he the owner of tokens.

What I am looking for, is to sign the transaction using the DAI user private key, but the gas fee should be paid by some other wallet.

I am using standard ERC20 Ethereum smart contract designed using solidity, and using ethers.js to interact with the smart contract.

1

Typically the one who signs a transaction also pays for the transaction. However, this doesn't have to be the case.

What you are looking for is something called meta transactions. A user signs a transaction he wishes to send to the blockchain and then hands the transaction to a third party which actually sends the transaction for the user (and pays for the gas). It's not a trivial thing to implement but once it's done right it should work. For some reason it's not very popular (yet).

Here's one article about the topic: https://medium.com/@austin_48503/ethereum-meta-transactions-90ccf0859e84

2
  • You are right, do you know how to build this over ethers.js?
    – DIGVJSS
    Oct 2 '19 at 11:21
  • Sorry, no idea about ethers.js . As I said, it's not very trivial to set this up. Oct 2 '19 at 11:26
0

Besides mentioned in another reply meta-transactions there are at least two other options:

  1. Use similar to the meta-transactions approach on the level of smart-contract called Gas Stations Network - more details could be found for example at: https://docs.portis.io/#/gas-relay
  2. Sponsor operation by transferring required amount of ETHs from another account before it initiation. That could be easily implemented on the level of ethers.js calls. The scenario could be the following:
  • in you app you have users that perform some blockchain operations and you want to cover gas fees for them
  • before doing each operation you could estimate gas fee
  • transfer from some main app wallet estimated ETHs amount to the user account
  • initiate user operation on blockchain

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.