We all know that gas limit for EOA to EOA transfer is 21000. I am got stuck at a point and unable to get dynamic gas limit estimation for "payable" smart contract using Web3.

When sending Ether from EOA to some external smart contract then facing "out of gas" error, because Web3's function estimateGas()

  to: EOA/Smart Contract address,
  value: web3.utils.toHex(ethAmount)

always return 21000, regardless of the "to" address whether its EOA or Smart contract.

Could you please help me figure out this issue.


  • If you only provide an address, the system has no way of knowing that the endpoint is a contract and just gives you the default minimum gas usage of 21000. For the best estimate it should have access to the actual source code but I don't know how to do that. Jun 17, 2020 at 11:15

1 Answer 1


Someone correct me if I'm wrong, but 21000 is not the gas limit. Remember that the gas limit is what the sender is willing to pay at most for the execution of the transaction. On the other hand, each opcode carries a gas price as you can see in the picture. Then the cost of performing a simple transaction is 21000, but if more opcodes are executed, the gas price of the transaction will increase (the prices of each opcode vary over time).

opcode prices

  • so that's the reason cause estimateGas() always returns 21000. It's simply returning the opcode price
    – Joncarre
    Jun 16, 2020 at 13:16
  • Thanks @joncarre, we know when we transfer eth from EOA to EOA then gas limit is 21000 always, the transaction will not consume more than 21000 gas limit. But recently we encounter a new use case as I have explained above, How to calculate "gas limit" for tx from EOA to paypable smart contract. Jun 17, 2020 at 9:17

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.