Function ink_env::call::build_create
source · [−]pub fn build_create<E, R>(
) -> CreateBuilder<E, Unset<E::Hash>, Unset<u64>, Unset<E::Balance>, Unset<ExecutionInput<EmptyArgumentList>>, Unset<Salt>, R> where
E: Environment,
R: FromAccountId<E>,
Expand description
Returns a new CreateBuilder
to build up the parameters to a cross-contract instantiation.
Example
The below example shows instantiation of contract of type MyContract
.
The used constructor:
- has a selector equal to
0xDEADBEEF
- is provided with 4000 units of gas for its execution
- is provided with 25 units of transferred value for the new contract instance
- receives the following arguments in order
- an
i32
with value42
- a
bool
with valuetrue
- an array of 32
u8
with value0x10
- an
ⓘ
let my_contract: MyContract = build_create::<DefaultEnvironment, MyContract>()
.code_hash(Hash::from([0x42; 32]))
.gas_limit(4000)
.endowment(25)
.exec_input(
ExecutionInput::new(Selector::new([0xDE, 0xAD, 0xBE, 0xEF]))
.push_arg(42)
.push_arg(true)
.push_arg(&[0x10u8; 32])
)
.salt_bytes(&[0xDE, 0xAD, 0xBE, 0xEF])
.params()
.instantiate()
.unwrap();
Note: The shown example panics because there is currently no cross-calling support in the off-chain testing environment. However, this code should work fine in on-chain environments.