Environment Functions
ink! exposes a number of handy environment functions. A full overview is found here.
In an #[ink(constructor)]
use Self::env()
to access those,
in an #[ink(message)]
use self.env()
.
So e.g. Self::env().caller()
or self.env().caller()
.
Some handy functions include:
caller()
: Returns the address of the caller of the executed contract.account_id()
: Returns the account ID of the executed contract.balance()
: Returns the balance of the executed contract.block_number()
: Returns the current block number.emit_event(…)
: Emits an event with the given event data.transfer(…)
: Transfers value from the contract to the destination account ID.hash_bytes(…)
: Conducts the crypto hash of the given input and stores the result in output.- …and many more.