3

I'm trying to understand the breakdown of the storage costs for smart contracts. My understanding is that a smart contract has some 'code' which is immutable, and some 'storage' which is mutable. Or in other words there is the storage part of the contract can be updated by future operations, whereas the contract code cannot be.

For example, if I store a variable of length 4 bytes in the storage part, would that have the same cost as the contract 'code' having a hard-coded variable of 4 bytes?

If not, is there any intuition or ballpark estimate of what the relative costs might be? Does it depend on how the storage is used in the code?

1 Answer 1

5

Do bytes in the contract code cost the same as bytes in the contract storage?

Yes. In both cases the cost is 0.25 tez per kilobyte. These are not fees that go to the baker including the operation, they are simply burnt.

1
  • 2
    The answer is obviously right (as always). Inlining data can save or waste bytes just because of how code is built (duplicating data is costly, accessing some field in the storage is not free).
    – FFF
    Jun 1, 2021 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.