TransWikia.com

Michelson: Parameter vs Storage

Tezos Asked by user5177 on August 19, 2021

I’m struggling to process what the difference between parameter and storage is in Michelson. From what I’ve been reading, it just looks like two different types of inputs to a contract. So how should I decide whether an entry point should be nested under parameter or storage? And what is the difference between initial storage value and final storage value? What exactly is being stored in storage anyway? Thank you

One Answer

The difference is very simple :) The parameter is made of data that are sent to the contract with a transaction while the storage holds the state of the contract (i.e all the data that the contract saves to be reused later). It is true that both the storage and the parameter can be seen as inputs because they are fed to the contract at the beginning of its execution, but the parameter comes from the "outside" while the storage comes from the "inside".
The initial storage value is the one passed to the contract at the beginning of the execution and the final storage value is the one generated by the contract. If you have a contract that adds a number sent in the parameter to a number in the storage, let's say 5 in the parameter and 6 in the storage, the initial storage will be 6 but the final storage will be 11. If you send another transaction with 4 as a parameter, the initial storage will be 11 and the final storage will be 15.
Finally, the storage can hold any kind of value you need, from simple ones like int or timestamp to more complex ones like pair or big_map.

Correct answer by Claude Barde on August 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP