Trait pallet_contracts::chain_extension::ChainExtension[][src]

pub trait ChainExtension<C: Config> {
    fn call<E>(
        func_id: u32,
        env: Environment<'_, '_, E, InitState>
    ) -> Result<RetVal>
    where
        E: Ext<T = C>,
        <E::T as SysConfig>::AccountId: UncheckedFrom<<E::T as SysConfig>::Hash> + AsRef<[u8]>
; fn enabled() -> bool { ... } }
Expand description

A trait used to extend the set of contract callable functions.

In order to create a custom chain extension this trait must be implemented and supplied to the pallet contracts configuration trait as the associated type of the same name. Consult the module documentation for a general explanation of chain extensions.

Required methods

Call the chain extension logic.

This is the only function that needs to be implemented in order to write a chain extensions. It is called whenever a contract calls the seal_call_chain_extension imported wasm function.

Parameters

  • func_id: The first argument to seal_call_chain_extension. Usually used to determine which function to realize.
  • env: Access to the remaining arguments and the execution environment.

Return

In case of Err the contract execution is immediately suspended and the passed error is returned to the caller. Otherwise the value of RetVal determines the exit behaviour.

Provided methods

Determines whether chain extensions are enabled for this chain.

The default implementation returns true. Therefore it is not necessary to overwrite this function when implementing a chain extension. In case of false the deployment of a contract that references seal_call_chain_extension will be denied and calling this function will return NoChainExtension without first calling into call.

Implementations on Foreign Types

Implementation that indicates that no chain extension is available.

Implementors