Attribute Macro cosmwasm_schema::cw_serde

source ·
#[cw_serde]
Expand description

An attribute macro that annotates types with things they need to be properly (de)serialized for use in CosmWasm contract messages and/or responses, and also for schema generation.

This derives things like serde::Serialize or schemars::JsonSchema, makes sure variants are snake_case in the resulting JSON, and so forth.

§Example

use cosmwasm_schema::{cw_serde, QueryResponses};

#[cw_serde]
pub struct InstantiateMsg {
    owner: String,
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(Vec<String>)]
    Denoms {},
    #[returns(String)]
    AccountName { account: String },
}