deps.storage, and the examples below show how to save/load data to/from there with a storage key.
&[u8]suffices. People often prefer generating these keys from strings as shown in the example below.
state.rs, and then imported to
contract.rs. However, since storage keys are just constants, they could be declared anywhere in the contract.
state.rsof most secret contract templates.
valuecan be of any Struct type. The only condition is that this Struct must derive the Serialize and Deserialize traits from serde with the following line above its Struct declaration.
may_load()which wraps any data inside within an option. Returning
Noneif there is no value saved with that key, and returning
Some(value)if there is some value saved. An example function for this is:
secret-toolkit) to serde the data being saved/read on the smart contract. However, bincode2 uses floats when deserializing rust enum variants, thus, bincode2 cannot serde enum variants in cosmwasm. This is why cosmwasm uses Json serde by default, not bincode2.
secret-toolkitto serde structs that use enums. This also creates the need for for new wrapper functions