pub trait Version2 {
    // Required methods
    fn set_storage(
        key_ptr: u32,
        key_len: u32,
        value_ptr: u32,
        value_len: u32
    ) -> Result<u32, TrapReason>;
    fn call(
        flags: u32,
        callee_ptr: u32,
        ref_time_limit: u64,
        proof_size_limit: u64,
        deposit_ptr: u32,
        value_ptr: u32,
        input_data_ptr: u32,
        input_data_len: u32,
        output_ptr: u32,
        output_len_ptr: u32
    ) -> Result<ReturnCode, TrapReason>;
    fn instantiate(
        code_hash_ptr: u32,
        ref_time_limit: u64,
        proof_size_limit: u64,
        deposit_ptr: u32,
        value_ptr: u32,
        input_data_ptr: u32,
        input_data_len: u32,
        address_ptr: u32,
        address_len_ptr: u32,
        output_ptr: u32,
        output_len_ptr: u32,
        salt_ptr: u32,
        salt_len: u32
    ) -> Result<ReturnCode, TrapReason>;
    fn seal_set_storage(
        key_ptr: u32,
        key_len: u32,
        value_ptr: u32,
        value_len: u32
    ) -> Result<u32, TrapReason>;
}
Expand description

All functions available in the seal2 module

Required Methods§

source

fn set_storage( key_ptr: u32, key_len: u32, value_ptr: u32, value_len: u32 ) -> Result<u32, TrapReason>

Set the value at the given key in the contract storage.

The key and value lengths must not exceed the maximums defined by the contracts module parameters. Specifying a value_len of zero will store an empty value.

Parameters
  • key_ptr: pointer into the linear memory where the location to store the value is placed.
  • key_len: the length of the key in bytes.
  • value_ptr: pointer into the linear memory where the value to set is placed.
  • value_len: the length of the value in bytes.
Return Value

Returns the size of the pre-existing value at the specified key if any. Otherwise SENTINEL is returned as a sentinel value.

Wasm Import Statement
(import "seal2" "set_storage" (func ...))
source

fn call( flags: u32, callee_ptr: u32, ref_time_limit: u64, proof_size_limit: u64, deposit_ptr: u32, value_ptr: u32, input_data_ptr: u32, input_data_len: u32, output_ptr: u32, output_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>

Make a call to another contract.

The callees output buffer is copied to output_ptr and its length to output_len_ptr. The copy of the output buffer can be skipped by supplying the sentinel value of SENTINEL to output_ptr.

Parameters
  • flags: See crate::wasm::runtime::CallFlags for a documentation of the supported flags.
  • callee_ptr: a pointer to the address of the callee contract. Should be decodable as an T::AccountId. Traps otherwise.
  • ref_time_limit: how much ref_time Weight to devote to the execution.
  • proof_size_limit: how much proof_size Weight to devote to the execution.
  • deposit_ptr: a pointer to the buffer with value of the storage deposit limit for the call. Should be decodable as a T::Balance. Traps otherwise. Passing SENTINEL means setting no specific limit for the call, which implies storage usage up to the limit of the parent call.
  • value_ptr: a pointer to the buffer with value, how much value to send. Should be decodable as a T::Balance. Traps otherwise.
  • input_data_ptr: a pointer to a buffer to be used as input data to the callee.
  • input_data_len: length of the input data buffer.
  • output_ptr: a pointer where the output buffer is copied to.
  • output_len_ptr: in-out pointer to where the length of the buffer is read from and the actual length is written to.
Errors

An error means that the call wasn’t successful output buffer is returned unless stated otherwise.

  • ReturnCode::CalleeReverted: Output buffer is returned.
  • ReturnCode::CalleeTrapped
  • ReturnCode::TransferFailed
  • ReturnCode::NotCallable
Wasm Import Statement
(import "seal2" "call" (func ...))
Unstable

This function is unstable and it is a subject to change (or removal) in the future. Do not deploy a contract using it to a production chain.

source

fn instantiate( code_hash_ptr: u32, ref_time_limit: u64, proof_size_limit: u64, deposit_ptr: u32, value_ptr: u32, input_data_ptr: u32, input_data_len: u32, address_ptr: u32, address_len_ptr: u32, output_ptr: u32, output_len_ptr: u32, salt_ptr: u32, salt_len: u32 ) -> Result<ReturnCode, TrapReason>

Instantiate a contract with the specified code hash.

This function creates an account and executes the constructor defined in the code specified by the code hash. The address of this new account is copied to address_ptr and its length to address_len_ptr. The constructors output buffer is copied to output_ptr and its length to output_len_ptr. The copy of the output buffer and address can be skipped by supplying the sentinel value of SENTINEL to output_ptr or address_ptr.

Parameters
  • code_hash_ptr: a pointer to the buffer that contains the initializer code.
  • ref_time_limit: how much ref_time Weight to devote to the execution.
  • proof_size_limit: how much proof_size Weight to devote to the execution.
  • deposit_ptr: a pointer to the buffer with value of the storage deposit limit for instantiation. Should be decodable as a T::Balance. Traps otherwise. Passing SENTINEL means setting no specific limit for the call, which implies storage usage up to the limit of the parent call.
  • value_ptr: a pointer to the buffer with value, how much value to send. Should be decodable as a T::Balance. Traps otherwise.
  • input_data_ptr: a pointer to a buffer to be used as input data to the initializer code.
  • input_data_len: length of the input data buffer.
  • address_ptr: a pointer where the new account’s address is copied to. SENTINEL means not to copy.
  • address_len_ptr: pointer to where put the length of the address.
  • output_ptr: a pointer where the output buffer is copied to. SENTINEL means not to copy.
  • output_len_ptr: in-out pointer to where the length of the buffer is read from and the actual length is written to.
  • salt_ptr: Pointer to raw bytes used for address derivation. See fn contract_address.
  • salt_len: length in bytes of the supplied salt.
Errors

Please consult the ReturnCode enum declaration for more information on those errors. Here we only note things specific to this function.

An error means that the account wasn’t created and no address or output buffer is returned unless stated otherwise.

  • ReturnCode::CalleeReverted: Output buffer is returned.
  • ReturnCode::CalleeTrapped
  • ReturnCode::TransferFailed
  • ReturnCode::CodeNotFound
Wasm Import Statement
(import "seal2" "instantiate" (func ...))
Unstable

This function is unstable and it is a subject to change (or removal) in the future. Do not deploy a contract using it to a production chain.

source

fn seal_set_storage( key_ptr: u32, key_len: u32, value_ptr: u32, value_len: u32 ) -> Result<u32, TrapReason>

This is just an alias function to set_storage() with backwards-compatible prefixed identifier.

Wasm Import Statement
(import "seal2" "seal_set_storage" (func ...))

Implementors§