3

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.

2 Answers 2

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.

2
  • I am facing same problem, when calculating fee limit its always returning 21000, how to dynamically calculate the "Gas limit"? Commented Jun 15, 2020 at 12:18
  • @goodvibration by your bonus content, it means that transferring ether from on smart contract to another costs 21.000 + 2300? Commented Feb 8, 2022 at 16:08
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 and acknowledge you have read our privacy policy.

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