Trait pallet_contracts::chain_extension::Ext[][src]

pub trait Ext: Sealed {
    type T: Config;
Show 23 methods fn call(
        &mut self,
        gas_limit: Weight,
        to: <Self::T as Config>::AccountId,
        value: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance,
        input_data: Vec<u8>,
        allows_reentry: bool
    ) -> Result<ExecReturnValue, ExecError>;
fn instantiate(
        &mut self,
        gas_limit: Weight,
        code: <Self::T as Config>::Hash,
        value: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance,
        input_data: Vec<u8>,
        salt: &[u8]
    ) -> Result<(<Self::T as Config>::AccountId, ExecReturnValue), ExecError>;
fn terminate(
        &mut self,
        beneficiary: &<Self::T as Config>::AccountId
    ) -> Result<(), DispatchError>;
fn transfer(
        &mut self,
        to: &<Self::T as Config>::AccountId,
        value: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance
    ) -> DispatchResult;
fn get_storage(&mut self, key: &[u8; 32]) -> Option<Vec<u8>>;
fn set_storage(
        &mut self,
        key: [u8; 32],
        value: Option<Vec<u8>>
    ) -> DispatchResult;
fn caller(&self) -> &<Self::T as Config>::AccountId;
fn address(&self) -> &<Self::T as Config>::AccountId;
fn balance(
        &self
    ) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance;
fn value_transferred(
        &self
    ) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance;
fn now(&self) -> &<<Self::T as Config>::Time as Time>::Moment;
fn minimum_balance(
        &self
    ) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance;
fn contract_deposit(
        &self
    ) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance;
fn random(
        &self,
        subject: &[u8]
    ) -> (<Self::T as Config>::Hash, <Self::T as Config>::BlockNumber);
fn deposit_event(
        &mut self,
        topics: Vec<<Self::T as Config>::Hash>,
        data: Vec<u8>
    );
fn block_number(&self) -> <Self::T as Config>::BlockNumber;
fn max_value_size(&self) -> u32;
fn get_weight_price(
        &self,
        weight: Weight
    ) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance;
fn schedule(&self) -> &Schedule<Self::T>;
fn gas_meter(&mut self) -> &mut GasMeter<Self::T>;
fn append_debug_buffer(&mut self, msg: &str) -> bool;
fn call_runtime(
        &self,
        call: <Self::T as Config>::Call
    ) -> DispatchResultWithPostInfo;
fn ecdsa_recover(
        &self,
        signature: &[u8; 65],
        message_hash: &[u8; 32]
    ) -> Result<[u8; 33], ()>;
}
Expand description

An interface that provides access to the external environment in which the smart-contract is executed.

This interface is specialized to an account of the executing code, so all operations are implicitly performed on that account.

Note

This trait is sealed and cannot be implemented by downstream crates.

Associated Types

Required methods

Call (possibly transferring some amount of funds) into the specified account.

Returns the original code size of the called contract.

Return Value

Result<(ExecReturnValue, CodeSize), (ExecError, CodeSize)>

Instantiate a contract from the given code.

Returns the original code size of the called contract. The newly created account will be associated with code. value specifies the amount of value transferred from this to the newly created account (also known as endowment).

Return Value

Result<(AccountId, ExecReturnValue, CodeSize), (ExecError, CodeSize)>

Transfer all funds to beneficiary and delete the contract.

Since this function removes the self contract eagerly, if succeeded, no further actions should be performed on this Ext instance.

This function will fail if the same contract is present on the contract call stack.

Transfer some amount of funds into the specified account.

Returns the storage entry of the executing account by the given key.

Returns None if the key wasn’t previously set by set_storage or was deleted.

Sets the storage entry by the given key to the specified value. If value is None then the storage entry is deleted.

Returns a reference to the account id of the caller.

Returns a reference to the account id of the current contract.

Returns the balance of the current contract.

The value_transferred is already added.

Returns the value transferred along with this call or as endowment.

Returns a reference to the timestamp of the current block

Returns the minimum balance that is required for creating an account.

Returns the deposit required to instantiate a contract.

Returns a random number for the current block with the given subject.

Deposit an event with the given topics.

There should not be any duplicates in topics.

Returns the current block number.

Returns the maximum allowed size of a storage item.

Returns the price for the specified amount of weight.

Get a reference to the schedule used by the current call.

Get a mutable reference to the nested gas meter.

Append a string to the debug buffer.

It is added as-is without any additional new line.

This is a no-op if debug message recording is disabled which is always the case when the code is executing on-chain.

Returns true if debug message recording is enabled. Otherwise false is returned.

Call some dispatchable and return the result.

Recovers ECDSA compressed public key based on signature and message hash.

Implementors