Factory Contracts
How to create Factory contracts
// example of an Instantiate Msg
#[derive(serde::Serialize, serde::Deserialize)]
pub struct OffspringInstantiateMsg {
pub example_field: i32,
}use cosmwasm_std::{SubMsg, Response};
use secret_toolkit::utils::{InitCallback};const OFFSPRING_INSTANTIATE_REPLY_ID: u64 = 1;
// Implement InitCallback on the OffsprintInit message
// to be able to convert it to cosmosMsg
impl InitCallback for OffspringInstantiateMsg {
const BLOCK_SIZE: usize = BLOCK_SIZE;
}
// populate the message
let init_msg = OffspringInstantiateMsg {
example_field: 1,
};
// build a submessage from the offspring init message
let init_submsg = SubMsg::reply_always(
initmsg.to_cosmos_msg(
"example_label".to_string(), // label for offspring contract
1, // offspring code id
"d519793af2...".to_string(), // offspring code hash
None, // funds amount
)?,
OFFSPRING_INSTANTIATE_REPLY_ID,
);
// then build the response with the submessage
Ok(Response::new().add_submessage(init_submsg))Last updated
Was this helpful?