Contract - module call
Explanation of executing modules inside a CosmWasm contract using sending Native SCRT as an example.
#[entry_point]
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: ExecuteMsg // this is a custom struct defined in your msg.rs
) -> StdResult<Response> {
// example: send 33 uscrt
let coins_to_send: Vec<Coin> = vec![Coin {
denom: "uscrt".to_string(),
amount: Uint128::from(33u128),
}];
let message = CosmosMsg::Bank(BankMsg::Send {
// replace with recipient of your choice
to_address: info.sender.clone().into_string(),
amount: coins_to_send,
});
let res = Response::new().add_message(message);
Ok(res)
}Transaction logs
Last updated
Was this helpful?