instantiate_with_code: TxDescriptor<{
    code: Binary;
    data: Binary;
    gas_limit: {
        proof_size: bigint;
        ref_time: bigint;
    };
    salt?: FixedSizeBinary<32>;
    storage_deposit_limit: bigint;
    value: bigint;
}>

Instantiates a new contract from the supplied code optionally transferring some balance.

This dispatchable has the same effect as calling [Self::upload_code] + [Self::instantiate]. Bundling them together provides efficiency gains. Please also check the documentation of [Self::upload_code].

Parameters

  • value: The balance to transfer from the origin to the newly created contract.
  • gas_limit: The gas limit enforced when executing the constructor.
  • storage_deposit_limit: The maximum amount of balance that can be charged/reserved from the caller to pay for the storage consumed.
  • code: The contract code to deploy in raw bytes.
  • data: The input data to pass to the contract constructor.
  • salt: Used for the address derivation. If Some is supplied then CREATE2 semantics are used. If None then CRATE1 is used.

Instantiation is executed as follows:

  • The supplied code is deployed, and a code_hash is created for that code.
  • If the code_hash already exists on the chain the underlying code will be shared.
  • The destination address is computed based on the sender, code_hash and the salt.
  • The smart-contract account is created at the computed address.
  • The value is transferred to the new account.
  • The deploy function is executed in the context of the newly-created account.