Expand description
The ink_env
utilities used to interoperate with the contract executor.
Mainly provides entities to work on a contract’s storage as well as high-level collections on top of those. Also provides environmental utilities, such as storage allocators, FFI to interface with FRAME contracts and a primitive blockchain emulator for simple off-chain testing.
Modules§
- call
- Utilities to call or instantiate contracts on the chain.
- chain_
extension - Definitions and utilities for calling chain extension methods.
- hash
- Provides type definitions and traits for the built-in cryptographic hashes.
- reflect
- Definitions and utilities for ink! smart contract static reflection.
- test
- Operations on the off-chain testing environment.
- types
Macros§
- pay_
with_ call - Prepend contract message call with value transfer. Used for tests in off-chain environment.
Structs§
- Call
Flags - Flags used to change the behaviour of
seal_call
andseal_delegate_call
. - Return
Flags - Flags used by a contract to customize exit behaviour.
Enums§
- Default
Environment - The fundamental types of the default configuration.
- Dispatch
Error - An error that can occur during dispatch of ink! dispatchables.
todo: add tests for other errors beside
PaidUnpayableMessage
- Error
- Errors that can be encountered upon environmental interaction.
- NoChain
Extension - Placeholder for chains that have no defined chain extension.
- Return
Error Code - Every error that can be returned to a contract when it calls any of the host functions.
Constants§
- BUFFER_
SIZE - The capacity of the static buffer.
Usually set to 16 kB.
Can be modified by setting
INK_STATIC_BUFFER_SIZE
environmental variable.
Traits§
- Account
IdGuard - todo remove
A trait to enforce that a type should be an
Environment::AccountId
. - Codec
AsType - Contract
Env - Stores the used host environment type of the ink! smart contract.
- Contract
Reference - Refers to the generated ink! smart contract reference type.
- Contract
Reverse Reference - Refers back to the original contract from the generated ink! smart contract reference type.
- Decode
Dispatch - Decodes an ink! dispatch input into a known selector and its expected parameters.
- Environment
- The environmental types usable by contracts defined with ink!.
- Event
- Implemented by event types to guide the event topic serialization using the topics builder.
- From
Little Endian - Allows to instantiate a type from its little-endian bytes representation.
Functions§
- account_
id - Returns the account ID of the executed contract.
- address
- Returns the address of the executed contract.
- balance
- Returns the balance of the executed contract.
- block_
number - Returns the current block number.
- block_
timestamp - Returns the current block timestamp.
- call_
runtime - Tries to trigger a runtime dispatchable, i.e. an extrinsic from a pallet.
- caller
- Returns the address of the caller of the executed contract.
- caller_
is_ origin - Checks whether the caller of the current contract is the origin of the whole call stack.
- caller_
is_ root - Checks whether the caller of the current contract is root.
- clear_
contract_ storage - Clears the contract’s storage entry under the given storage key.
- code_
hash - Retrieves the code hash of the contract at the specified account id.
- contains_
contract_ storage - Checks whether there is a value stored under the given storage key in the contract’s storage.
- decode_
input - Returns the execution input to the executed contract and decodes it as
T
. - ecdsa_
recover - Recovers the compressed ECDSA public key for given
signature
andmessage_hash
, and stores the result inoutput
. - ecdsa_
to_ eth_ address - Returns an Ethereum address from the ECDSA compressed public key.
- emit_
event - Emits an event with the given event data.
- get_
contract_ storage - Returns the value stored under the given storage key in the contract’s storage if any.
- hash_
bytes - Conducts the crypto hash of the given input and stores the result in
output
. - hash_
encoded - Conducts the crypto hash of the given encoded input and stores the result in
output
. - instantiate_
contract - Instantiates another contract.
- invoke_
contract - Invokes a contract message and returns its result.
- invoke_
contract_ delegate - Invokes a contract message via delegate call and returns its result.
- is_
contract - Checks whether the specified account is a contract.
- minimum_
balance - Returns the minimum balance that is required for creating an account (i.e. the chain’s existential deposit).
- own_
code_ hash - Retrieves the code hash of the currently executing contract.
- return_
value - Returns the value back to the caller of the executed contract.
- return_
value_ solidity - Returns the Solidity ABI encoded value back to the caller of the executed contract.
- set_
code_ hash - Replace the contract code at the specified address with new code.
- set_
contract_ storage - Writes the value to the contract storage under the given storage key and returns the size of pre-existing value if any.
- sr25519_
verify - Verifies a sr25519 signature.
- take_
contract_ storage - Removes the
value
atkey
, returning the previousvalue
atkey
from storage. - terminate_
contract - Terminates the existence of the currently executed smart contract.
- transfer
- Transfers value from the contract to the destination account ID.
- transferred_
value - Returns the transferred value for the contract execution.
- weight_
to_ fee - Returns the price for the specified amount of gas.
- xcm_
execute - Execute an XCM message locally, using the contract’s address as the origin.
- xcm_
send - Send an XCM message, using the contract’s address as the origin.
Type Aliases§
- Balance
- The default balance type.
- Block
Number - The default block number type.
- Gas
- The default gas type.
- Result
- A result of environmental operations.
- Timestamp
- The default timestamp type.