pub trait Version1 {
Show 22 methods // Required methods fn set_storage( key_ptr: u32, value_ptr: u32, value_len: u32 ) -> Result<u32, TrapReason>; fn clear_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>; fn get_storage( key_ptr: u32, key_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>; fn contains_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>; fn call( flags: u32, callee_ptr: u32, gas: u64, 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, gas: u64, 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 terminate(beneficiary_ptr: u32) -> Result<(), TrapReason>; fn weight_to_fee( ref_time_limit: u64, proof_size_limit: u64, out_ptr: u32, out_len_ptr: u32 ) -> Result<(), TrapReason>; fn gas_left(out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason>; fn random( subject_ptr: u32, subject_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<(), TrapReason>; fn restore_to( _dest_ptr: u32, _code_hash_ptr: u32, _rent_allowance_ptr: u32, _delta_ptr: u32, _delta_count: u32 ) -> Result<(), TrapReason>; fn set_rent_allowance(_value_ptr: u32) -> Result<(), TrapReason>; fn seal_set_storage( key_ptr: u32, value_ptr: u32, value_len: u32 ) -> Result<u32, TrapReason>; fn seal_clear_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>; fn seal_get_storage( key_ptr: u32, key_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>; fn seal_contains_storage( key_ptr: u32, key_len: u32 ) -> Result<u32, TrapReason>; fn seal_call( flags: u32, callee_ptr: u32, gas: u64, value_ptr: u32, input_data_ptr: u32, input_data_len: u32, output_ptr: u32, output_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>; fn seal_instantiate( code_hash_ptr: u32, gas: u64, 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_terminate(beneficiary_ptr: u32) -> Result<(), TrapReason>; fn seal_random( subject_ptr: u32, subject_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<(), TrapReason>; fn seal_restore_to( _dest_ptr: u32, _code_hash_ptr: u32, _rent_allowance_ptr: u32, _delta_ptr: u32, _delta_count: u32 ) -> Result<(), TrapReason>; fn seal_set_rent_allowance(_value_ptr: u32) -> Result<(), TrapReason>;
}
Expand description

All functions available in the seal1 module

Required Methods§

source

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

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

This version is to be used with a fixed sized storage key. For runtimes supporting transparent hashing, please use the newer version of this function.

The value length must not exceed the maximum 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.
  • 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 "seal1" "set_storage" (func ...))
source

fn clear_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>

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

Parameters
  • key_ptr: pointer into the linear memory where the key is placed.
  • key_len: the length of the key 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 "seal1" "clear_storage" (func ...))
source

fn get_storage( key_ptr: u32, key_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>

Retrieve the value under the given key from storage.

This version is to be used with a fixed sized storage key. For runtimes supporting transparent hashing, please use the newer version of this function.

The key length must not exceed the maximum defined by the contracts module parameter.

Parameters
  • key_ptr: pointer into the linear memory where the key of the requested value is placed.
  • key_len: the length of the key in bytes.
  • out_ptr: pointer to the linear memory where the value is written to.
  • out_len_ptr: in-out pointer into linear memory where the buffer length is read from and the value length is written to.
Errors
  • ReturnCode::KeyNotFound
Wasm Import Statement
(import "seal1" "get_storage" (func ...))
source

fn contains_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>

Checks whether there is a value stored under the given key.

The key length must not exceed the maximum defined by the contracts module parameter.

Parameters
  • key_ptr: pointer into the linear memory where the key of the requested value is placed.
  • key_len: the length of the key 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 "seal1" "contains_storage" (func ...))
source

fn call( flags: u32, callee_ptr: u32, gas: u64, 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.

Equivalent to the newer seal2 version but works with ref_time Weight only. It is recommended to switch to the latest version, once it’s stabilized.

Wasm Import Statement
(import "seal1" "call" (func ...))
source

fn instantiate( code_hash_ptr: u32, gas: u64, 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.

Equivalent to the newer seal2 version but works with ref_time Weight only. It is recommended to switch to the latest version, once it’s stabilized.

Wasm Import Statement
(import "seal1" "instantiate" (func ...))
source

fn terminate(beneficiary_ptr: u32) -> Result<(), TrapReason>

Remove the calling account and transfer remaining free balance.

This function never returns. Either the termination was successful and the execution of the destroyed contract is halted. Or it failed during the termination which is considered fatal and results in a trap + rollback.

  • beneficiary_ptr: a pointer to the address of the beneficiary account where all where all remaining funds of the caller are transferred. Should be decodable as an T::AccountId. Traps otherwise.
Traps
  • The contract is live i.e is already on the call stack.
  • Failed to send the balance to the beneficiary.
  • The deletion queue is full.
Wasm Import Statement
(import "seal1" "terminate" (func ...))
source

fn weight_to_fee( ref_time_limit: u64, proof_size_limit: u64, out_ptr: u32, out_len_ptr: u32 ) -> Result<(), TrapReason>

Stores the price for the specified amount of weight into the supplied buffer.

Parameters
  • out_ptr: pointer to the linear memory where the returning value is written to. If the available space at out_ptr is less than the size of the value a trap is triggered.
  • out_len_ptr: in-out pointer into linear memory where the buffer length is read from and the value length is written to.

The data is encoded as T::Balance.

Note

It is recommended to avoid specifying very small values for ref_time_limit and proof_size_limit as the prices for a single gas can be smaller than the basic balance unit.

Wasm Import Statement
(import "seal1" "weight_to_fee" (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 gas_left(out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason>

Stores the amount of weight left into the supplied buffer.

The value is stored to linear memory at the address pointed to by out_ptr. out_len_ptr must point to a u32 value that describes the available space at out_ptr. This call overwrites it with the size of the value. If the available space at out_ptr is less than the size of the value a trap is triggered.

The data is encoded as Weight.

Wasm Import Statement
(import "seal1" "gas_left" (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 random( subject_ptr: u32, subject_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<(), TrapReason>

Deprecated

This function is deprecated and will be removed in future versions. No new code or contracts with this API can be deployed. Stores a random number for the current block and the given subject into the supplied buffer.

The value is stored to linear memory at the address pointed to by out_ptr. out_len_ptr must point to a u32 value that describes the available space at out_ptr. This call overwrites it with the size of the value. If the available space at out_ptr is less than the size of the value a trap is triggered.

The data is encoded as (T::Hash, frame_system::pallet_prelude::BlockNumberFor::).

Changes from v0

In addition to the seed it returns the block number since which it was determinable by chain observers.

Note

The returned seed should only be used to distinguish commitments made before the returned block number. If the block number is too early (i.e. commitments were made afterwards), then ensure no further commitments may be made and repeatedly call this on later blocks until the block number returned is later than the latest commitment.

Wasm Import Statement
(import "seal1" "random" (func ...))
source

fn restore_to( _dest_ptr: u32, _code_hash_ptr: u32, _rent_allowance_ptr: u32, _delta_ptr: u32, _delta_count: u32 ) -> Result<(), TrapReason>

Deprecated

This function is deprecated and will be removed in future versions. No new code or contracts with this API can be deployed. Was used to restore the given destination contract sacrificing the caller.

Note

The state rent functionality was removed. This is stub only exists for backwards compatibility

Wasm Import Statement
(import "seal1" "restore_to" (func ...))
source

fn set_rent_allowance(_value_ptr: u32) -> Result<(), TrapReason>

Deprecated

This function is deprecated and will be removed in future versions. No new code or contracts with this API can be deployed. Was used to set rent allowance of the contract.

Note

The state rent functionality was removed. This is stub only exists for backwards compatibility.

Wasm Import Statement
(import "seal1" "set_rent_allowance" (func ...))
source

fn seal_set_storage( key_ptr: 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 "seal1" "seal_set_storage" (func ...))
source

fn seal_clear_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>

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

Wasm Import Statement
(import "seal1" "seal_clear_storage" (func ...))
source

fn seal_get_storage( key_ptr: u32, key_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>

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

Wasm Import Statement
(import "seal1" "seal_get_storage" (func ...))
source

fn seal_contains_storage(key_ptr: u32, key_len: u32) -> Result<u32, TrapReason>

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

Wasm Import Statement
(import "seal1" "seal_contains_storage" (func ...))
source

fn seal_call( flags: u32, callee_ptr: u32, gas: u64, value_ptr: u32, input_data_ptr: u32, input_data_len: u32, output_ptr: u32, output_len_ptr: u32 ) -> Result<ReturnCode, TrapReason>

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

Wasm Import Statement
(import "seal1" "seal_call" (func ...))
source

fn seal_instantiate( code_hash_ptr: u32, gas: u64, 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>

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

Wasm Import Statement
(import "seal1" "seal_instantiate" (func ...))
source

fn seal_terminate(beneficiary_ptr: u32) -> Result<(), TrapReason>

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

Wasm Import Statement
(import "seal1" "seal_terminate" (func ...))
source

fn seal_random( subject_ptr: u32, subject_len: u32, out_ptr: u32, out_len_ptr: u32 ) -> Result<(), TrapReason>

Deprecated

This function is deprecated and will be removed in future versions. No new code or contracts with this API can be deployed. This is just an alias function to random() with backwards-compatible prefixed identifier.

Wasm Import Statement
(import "seal1" "seal_random" (func ...))
source

fn seal_restore_to( _dest_ptr: u32, _code_hash_ptr: u32, _rent_allowance_ptr: u32, _delta_ptr: u32, _delta_count: u32 ) -> Result<(), TrapReason>

Deprecated

This function is deprecated and will be removed in future versions. No new code or contracts with this API can be deployed. This is just an alias function to restore_to() with backwards-compatible prefixed identifier.

Wasm Import Statement
(import "seal1" "seal_restore_to" (func ...))
source

fn seal_set_rent_allowance(_value_ptr: u32) -> Result<(), TrapReason>

Deprecated

This function is deprecated and will be removed in future versions. No new code or contracts with this API can be deployed. This is just an alias function to set_rent_allowance() with backwards-compatible prefixed identifier.

Wasm Import Statement
(import "seal1" "seal_set_rent_allowance" (func ...))

Implementors§