0

Is there a way to pre-define a contracts storage when deploying it?

Say I want a mapping to be filled with 1000 entries but want to avoid having to pay gas for adding every entry on its own.

Since storage is just a key-value map, I was wondering if can't just hardcode its initial state.

| improve this question | | | | |
0

A contract storage can be modified in two cases:

  • At contract deployment
  • A function is called during a transaction
| improve this answer | | | | |
0

You can add the 1000 entries during deployment by modifying the constructor. But you will still have to pay for the gas consumed.

| improve this answer | | | | |

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.