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?

Yetispapa
  • 101
  • 3

2 Answers2

2

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.

egjlmn1
  • 441
  • 2
  • 17
0

It actually cost more gas to access an item in a mapping than when an item doesn't exist.

Ololade
  • 73
  • 7