Skip to main content


State is where a smart contract works with saving and retrieving data.

You can think of it much like a database interaction layer in a traditional application.

A contract is instantiated as defined in

State declared -

This is an example of TokenInfo being declared.

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub struct TokenInfo {
pub name: String,
pub symbol: String,
pub decimals: u8,
pub total_supply: Uint128,
pub mint: Option<MinterData>,

State initialised

Then the storage is initialized:

pub const TOKEN_INFO: Item<TokenInfo> = Item::new("token_info");

Here is an example of the instantiate function saving data.

let data = TokenInfo {
symbol: msg.symbol,
decimals: msg.decimals,
};, & data) ?;