10

ERC20 is an interface and not a contract definition. And since gas is paid for each executed machine instruction, it is not possible to specify precisely how much a call to transfer costs for an ERC20 contract. This will depend on how the ERC20 contract is implemented (in Solidity) and how it is compiled to EVM code.

However: is it possible to say something general about this gas costs or does there exists a reference implementation where we can precisely say how much such a method call costs? And does there exist a lower limit for this number?

By looking a ERC20 transfer calls on etherscan.io, it seems that the gas cost is between 50.000 and 105.000.

I have set the gas limit to 200.000 on a wallet that I have built. So far, I have not encountered an ERC20 transfer call that has exceeded this limit.

3
  • 1
    You answered your own question. Yes, ussually ERC20 transfers are arround those values. More precisely, in most contracts, they are bellow 100k gas, but as you've seen, it varies Mar 5, 2018 at 17:06
  • I might have to rephrase it or ask the question again. But I want more info: what is the lowest possible price (i.e.: given the optimal ERC20 code, how much gas would a transfer method call consume? What is the maximum gas that you could possibly pay on any existing ERC20 contracts that are actually being used?) Mar 5, 2018 at 22:22
  • 1
    It is sufficient. Dec 18, 2018 at 14:25

1 Answer 1

4

The only thing you can definitely tell is that it will not be below 21.000, which is the minimum transaction cost, and that it will not be above the gasLimit of the block. Everything else depends on the implementation of the contract. The average of existing tokens can be calculated based on block/tx data.

Moreover, you can dry run your transaction against your local node to get a pretty good estimate how much the transaction will cost.

Your Answer

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

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