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?
Ink Contracts: What Data Structures/Situations Are Best Suited To Contract Storage vs Events?
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/
#[ink(topic)]in the Event are indexed. Does that means are they searchable, if so, then where and how one can search?– Ganesh11Dec 16, 2022 at 1:39