According to the Yellow Paper, creating a transaction costs 21000 gas (regardless if it contains value) and creating a message call with non-zero call value costs at at least 9000 gas. Yet when I call Contract's default function in Remix (uses ethereumjs-vm) with a value of 1 ether, the entire transaction costs 28562. That means 7562 for execution. How could it be less than 9000?

pragma solidity ^0.5.0;

contract Helper {
    function () external payable {}

contract Contract {        
    function () external payable {
        [insert helper address here].transfer (1 ether);
  • Can you please cite (give a link) to the at least 9000 gas restriction? – goodvibration Mar 11 at 14:45
  • 1
    sure! It's called G_{callvalue} on page 25 of the Yellow Paper I say "at least" 9000 because there are usually other costs associated with CALL's (e.g. for transaction data). – Dominik Teiml Mar 11 at 14:52
  • That applies for [insert helper address here].call.value(1 ether) I believe. – goodvibration Mar 11 at 15:03
  • I think it applies here too. Look at what opcode is generated, it is still a CALL call. ;) – Dominik Teiml Mar 11 at 15:06
  • I did, there's a whole additional bunch of opcodes when you replace addr.transfer(1 ether) with addr.call.value(1 ether)(""). – goodvibration Mar 11 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.