This site requires Javascript to be enabled.

Entry points

In CosmWasm, entry points enable contracts to process messages and queries.

The primary handlers consist of:

  • Instantiate: This handles instantiation messages as defined by the InstantiateMsg struct.
  • Execute: This manages messages as defined by the ExecuteMsg enum, utilizing a pattern-matching statement.
  • Query: This addresses queries as defined by the QueryMsg enum, using pattern matching.

The execute and Query functions must match every variant in the enums they handle, while the instantiate function only needs to handle the struct it receives.

Typically, instantiate and execute have the type Result<Response, ContractError>, while Query has the type StdResult due to the underlying Cosmos SDK Querier.

As you can see from the code snippet below, these handlers are explicitly marked as entry points and are excluded from being bundled in the library:

#[cfg_attr(not(feature = "library"), entry_point)]pub fn instantiate(  deps: DepsMut,  _env: Env,  _info: MessageInfo,  msg: InstantiateMsg,) -> Result<Response, StdError> {  // ...etc}