0

In my smart contract, I have the following property

struct MyStruct {
    uint256 property1;
    uint256 property2;
}

mapping(address => MyStruct) private structs;

In one function, this struct is getting filled

...
structs[msg.sender] = MyStruct(
                    _property1,
                    _property
                );

Now my question, is the gas fee increased everytime the structs property is getting bigger, cause the nodes in the blockchain have to store more data?

1

When you create a mapping, solidity saves storage for that mapping. So adding new items to the map won't increase gas cost. You can look at this answer https://ethereum.stackexchange.com/a/8451/83751. You won't reach the maximum storage given to you since you have 2^256 slots.

Of course that if you try to access an item in the mapping that already exists, it will cost less gas than accessing one that doesn't exist.

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.