1

Using events to write data to the chain is great for registering information to the chain, especially information that you want a permanent record of. So my question is: under what circumstances should you use Contract Storage? What kinds of situations make Contract Storage a better store of data than an on-chain event? Is there a reason to prefer using contract storage over on-chain events? And what are the cons of using contract storage (or events)? I imagine that sometimes your data structures are better off in Contract Storage and sometimes your data structures are better off in an Event. How do you determine which to use when?

1 Answer 1

3

The contract storage is used to store the information about the contract (for example balances of users). Basically every value your contract will work with.

Emitting events is informational, they are used to keep track of changes in the state of the smart contract, and are particularly helpful when building decentralized applications. Also, you can not access them from the smart contract, so storing contract state to events would not be helpful.

You can read more about ink! events here: https://use.ink/basics/events/

1

Your Answer

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

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