I deployed the following contracts where one of the low level functions writes to a state variable and the other does not.

''' //SPDX-License-Identifier: MIT 

     pragma solidity <0.9.0;

     contract lowlevel_w{ 
        uint public balanceReceived;

        receive() external payable{ 
          balanceReceived += address(this).balance; } 

     contract lowlevel{ 
        receive() external payable{} 
       } '''

I then sent 2 ETH to each of the contracts and the gas costs were as following- lowlevel_w{}


Why does the second contract (lowlevel{}) have three different types of fee whereas the first contract (lowlevel_w{}) have only one? Is there any default gas limit for low-level interactions?

  • In the first image you aren't making a transaction, just calling the method balanceReceived()
    – 0xSanson
    Commented Dec 12, 2022 at 13:15

1 Answer 1


You have 2 contracts, but what is difference between them?? store data , and you store data in one of your contracts.

I mean when you transfer some ETH to lowlevel contract, you just pay gas for transaction fee (execution cost)

But when you transfer to lowlevel_w contract you updating some data 'balanceReceived' which you stored in blockchain, this line update your variable in blockchain:

balanceReceived += address(this).balance;

and you must pay some gas for doing this, for storing and updtating data on blockchain.

when you reading data from blockchain it doesn't need to pay gas, but when you want to add something or update or change something in blockchain you must pay gas.

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.