Expand description
Blockchain-specific methods available to the smart contract. This is a wrapper around a
low-level BlockchainInterface
. Unless you know what you are doing prefer using env::*
whenever possible. In case of cross-contract calls prefer using even higher-level API available
through callback_args
, callback_args_vec
, ext_contract
, Promise
, and PromiseOrValue
.
Functions§
- Aborts the current contract execution without a custom message. To include a message, use
panic_str
. - The balance attached to the given account. This includes the attached_deposit that was attached to the transaction
- The balance locked for potential validator staking.
- Compute alt_bn128 g1 multiexp.
- Compute alt_bn128 g1 sum.
- Compute pairing check
- The balance that was attached to the call that will be immediately deposited before the contract execution starts
- Returns the height of the block the transaction is being executed in.
- block_indexDeprecatedCurrent block index.
- Current block timestamp, i.e, number of non-leap-nanoseconds since January 1, 1970 0:00:00 UTC.
- Current block timestamp, i.e, number of non-leap-milliseconds since January 1, 1970 0:00:00 UTC.
- The id of the account that owns the current contract.
- Recovers an ECDSA signer address from a 32-byte message
hash
and a correspondingsignature
along withv
recovery byte. - Verifies signature of message using provided ED25519 Public Key
- Current epoch height.
- The input to the contract call serialized as bytes. If input is not provided returns
None
. - Returns
true
if the given account ID is valid andfalse
otherwise. - Hashes the random sequence of bytes using keccak256.
- Hashes the bytes using the Keccak-256 hash function. This returns a 32 byte hash.
- Hashes the random sequence of bytes using keccak512.
- Hashes the bytes using the Keccak-512 hash function. This returns a 64 byte hash.
- logDeprecatedLog the UTF-8 encodable message.
- Logs the string message message. This message is stored on chain.
- panicDeprecatedTerminates the execution of the program with the UTF-8 encoded message.
panic_str
should be used as the bytes are required to be UTF-8 - Terminates the execution of the program with the UTF-8 encoded message.
- The id of the account that was the previous contract in the chain of cross-contract calls. If this is the first contract, it is equal to
signer_account_id
. - The amount of gas attached to the call that can be used to pay for the gas fees.
- Creates a new promise which completes when time all promises passed as arguments complete.
- Creates a promise that will execute a method on account with given arguments and attaches the given amount and gas.
- If the current function is invoked by a callback we can access the execution results of the promises that caused the callback.
- If the current function is invoked by a callback we can access the execution results of the promises that caused the callback. This function returns the number of complete and incomplete callbacks.
- Consider the execution result of promise under
promise_idx
as execution result of this function. - Attaches the callback that is executed after promise pointed by
promise_idx
is complete. - Returns the random seed from the current block. This 32 byte hash is based on the VRF value from the block. This value is not modified in any way each time this function is called within the same method/block.
- Returns the random seed from the current block. This 32 byte hash is based on the VRF value from the block. This value is not modified in any way each time this function is called within the same method/block. Example of usage:
- Reads the content of the
register_id
. If register is not used returnsNone
. - Returns the size of the register. If register is not used returns
None
. - Hashes the bytes using the RIPEMD-160 hash function. This returns a 20 byte hash.
- Setups panic hook to expose error info to the blockchain.
- Hashes the random sequence of bytes using sha256.
- Hashes the bytes using the SHA-256 hash function. This returns a 32 byte hash.
- The id of the account that either signed the original transaction or issued the initial cross-contract call.
- The public key of the account that did the signing.
- Returns
true
if the contract state exists andfalse
otherwise. - Load the state of the given object.
- Price per 1 byte of storage from mainnet genesis config. TODO: will be using the host function when it will be available.
- Reads the most recent value that was evicted with
storage_write
orstorage_remove
command. - Checks if there is a key-value in the storage.
- Reads the value stored under the given key.
- Removes the value stored under the given key. If key-value existed returns
true
, otherwisefalse
. - Current total storage usage of this smart contract that this account would be paying for.
- Writes key-value into storage. If another key-value existed in the storage with the same key it returns
true
, otherwisefalse
. - The gas that was already burnt during the contract execution (cannot exceed
prepaid_gas
) - For a given account return its current stake. If the account is not a validator, returns 0.
- Returns the total stake of validators in the current epoch.
- Sets the blob of data as the return value of the contract.