#[entry_point]
Expand description
This attribute macro generates the boilerplate required to call into the contract-specific logic from the entry-points to the Wasm module.
It should be added to the contract’s init, handle, migrate and query implementations like this:
#[entry_point]
pub fn instantiate(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, StdError> {
}
#[entry_point]
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, StdError> {
}
#[entry_point]
pub fn query(
deps: Deps,
env: Env,
msg: QueryMsg,
) -> Result<QueryResponse, StdError> {
}
where InstantiateMsg
, ExecuteMsg
, and QueryMsg
are contract defined
types that implement DeserializeOwned + JsonSchema
.
§Set the version of the state of your contract
The VM will use this as a hint whether it needs to run the migrate function of your contract or not.
#[entry_point]
#[migrate_version(2)]
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult<Response> {
todo!();
}
It is also possible to assign the migrate version number to a given constant name:
const CONTRACT_VERSION: u64 = 66;
#[entry_point]
#[migrate_version(CONTRACT_VERSION)]
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg, migrate_info: MigrateInfo) -> StdResult<Response> {
todo!();
}