I am working on a chrome extension (crypto wallet) that lets you use one of our custom ERC20 token to make a purchase on websites. Most of the users of the extension don't have Ethereum in their accounts and won't be able to pay the transaction fee.

My research has yielded the following info:

  1. We can pay transaction fee on the senders behalf in the smart contract The user just has to sign a transaction, and we can use this signature in the smart contract to keep the validity of the transaction, while paying for the gas at the same time.

  2. My problem however is that I don't want to do this within a smart contract as it gets me to pay extra gas.

Is there a way I can save these signed transactions on a server, and then using my host language (Javascript) and web3 make changes to the signed transaction so that gas comes from one of my accounts? Is it even possible?

  • You mention transaction fee and gas as if they're different things, which is not usually the case. Is there some piece of context missing?
    – James_pic
    Jun 7, 2018 at 11:11
  • @James_pic not really, I meant the same. Transaction fee is definitely the gas you pay. Incase of executing a smart contract, I'll have to pay extra gas obviously Jun 7, 2018 at 11:14
  • @James_pic can you think of a way to do that? Jun 7, 2018 at 11:21

1 Answer 1


As it stands right now, the gas fee for a transaction must always be paid by tx.origin - the account whose private key signed the transaction. There are plans to change this, but it's unclear if and when it'll happen.

If you want to send a standard ERC-20 token from one account to another, you can do this in two ways:

  • Call transfer. In this case tokens will be transferred from msg.sender to the destination.
  • Call transferFrom. This allows tokens to be transferred from any account to any destination, provided that the account owner has pre-approved msg.sender to make the transfer, by calling approve.

If a user has a standard (non-contract) account, there is no way to make msg.sender match their account, without them also being tx.origin, and paying the gas fee. I can see two ways you could change this:

  • Get users to make a one-off call to approve, to allow your account to call transferFrom. This will require users to have ether in their accounts at least once.
  • Add an extra method to your ERC-20 contract, that allows users to sign a message (not a transaction - the contract can verify the signature using ecrecover), authorising a third party to make a transfer on their behalf.

Whilst none of these options strictly need smart contracts, if you do end up needing smart contracts, the extra gas used by a smart contract needn't be too high. The gas cost to call a smart contract from another contract is not that high - if there's no ether transferred, it's less than the cost to save a piece of data into a mapping. You will be making a contract call no matter what, because ERC-20 tokens are always contracts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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