pub trait Api {
    fn set_storage(
        key_ptr: u32,
        key_len: u32,
        value_ptr: u32,
        value_len: u32
    ) -> Result<u32, TrapReason>; fn seal_set_storage(
        key_ptr: u32,
        key_len: u32,
        value_ptr: u32,
        value_len: u32
    ) -> Result<u32, TrapReason>; }
Expand description

Every function in this trait represents (at least) one function that can be imported by a contract.

The function’s identifier is to be set as the name in the import definition. Where it is specifically indicated, an alias function having seal_-prefixed identifier and just the same signature and body, is also available (for backwards-compatibility purposes).

Required Methods§

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.

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

Implementors§