2

It is pretty clear that Ether transfer between accounts is 21,000 gas. Does the same apply for transferring Ether to Smart contract address, or does transfer from EOA to Smartcontract cost more gas? I tried to transfer Ether from an EOA to a Smartcontract with 21,000 gas and its failing with out of gas exception.

1

When transferring ether from an externally-owned account to a smart-contract account, the fallback function of the smart contract is executed (if it doesn't implement one, then the transaction reverts).

Therefore, the cost of such transaction is 21000 plus the cost of the fallback function itself.

If this function doesn't do anything except for (implicitly) receiving the funds, for example:

function () external payable {}

Then the cost will be just slightly higher than 21000.

Bonus fact:

When transferring ether from a smart-contract account to a smart-contract account, the fallback function of the (destination) smart contract is executed with a stipend of only 2300 gas, keeping it limited to a very small number of operations. This feature was incorporated at around September of 2016, in order to prevent the destination contract from acting maliciously.

1
  • I am facing same problem, when calculating fee limit its always returning 21000, how to dynamically calculate the "Gas limit"? – Surinder kumar Jun 15 '20 at 12:18
1

Transferring ETH to a smart contract wallet will cost slightly more gas than transferring to an EOA. For example, transferring ETH to an Authereum wallet costs ~21,084 gas. This is because the transaction will trigger the fallback function on the contract, and generally is additional processing that must be done when this happens. For example, this line on the Authereum contracts is what makes your transaction cost slightly more than 21,000 gas.

With that said, the wallet you are using to send the transaction should estimate the gas correctly.

Disclaimer: I am a co-founder of Authereum.

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.