Module near_sdk::env [−][src]
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.
Constants
| BLOCKCHAIN_INTERFACE | Low-level blockchain interface wrapped by the environment. Prefer using |
| STORAGE_PRICE_PER_BYTE | Price per 1 byte of storage from mainnet genesis config. TODO: will be using the host function when it will be available. |
Functions
| account_balance | The balance attached to the given account. This includes the attached_deposit that was attached to the transaction |
| account_locked_balance | The balance locked for potential validator staking. |
| attached_deposit | The balance that was attached to the call that will be immediately deposited before the contract execution starts |
| block_index | Current block index. |
| block_timestamp | Current block timestamp, i.e, number of non-leap-nanoseconds since January 1, 1970 0:00:00 UTC. |
| current_account_id | The id of the account that owns the current contract. |
| epoch_height | Current epoch height. |
| input | The input to the contract call serialized as bytes. If input is not provided returns |
| is_valid_account_id | Returns |
| keccak256 | Hashes the random sequence of bytes using keccak256. |
| keccak512 | Hashes the random sequence of bytes using keccak512. |
| log | Log the UTF-8 encodable message. |
| panic | Terminates the execution of the program with the UTF-8 encoded message. |
| predecessor_account_id | 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 |
| prepaid_gas | The amount of gas attached to the call that can be used to pay for the gas fees. |
| promise_and | Creates a new promise which completes when time all promises passed as arguments complete. |
| promise_batch_action_add_key_with_full_access | |
| promise_batch_action_add_key_with_function_call | |
| promise_batch_action_create_account | |
| promise_batch_action_delete_account | |
| promise_batch_action_delete_key | |
| promise_batch_action_deploy_contract | |
| promise_batch_action_function_call | |
| promise_batch_action_stake | |
| promise_batch_action_transfer | |
| promise_batch_create | |
| promise_batch_then | |
| promise_create | Creates a promise that will execute a method on account with given arguments and attaches the given amount and gas. |
| promise_result | If the current function is invoked by a callback we can access the execution results of the promises that caused the callback. |
| promise_results_count | 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. |
| promise_return | Consider the execution result of promise under |
| promise_then | Attaches the callback that is executed after promise pointed by |
| random_seed | Get random seed from the register. |
| read_register | Reads the content of the |
| register_len | Returns the size of the register. If register is not used returns |
| set_blockchain_interface | Replaces the current low-level blockchain interface accessible through |
| setup_panic_hook | Setups panic hook to expose error info to the blockchain. |
| sha256 | Hashes the random sequence of bytes using sha256. |
| signer_account_id | The id of the account that either signed the original transaction or issued the initial cross-contract call. |
| signer_account_pk | The public key of the account that did the signing. |
| state_exists | Returns |
| state_read | Load the state of the given object. |
| state_write | |
| storage_byte_cost | |
| storage_get_evicted | Reads the most recent value that was evicted with |
| storage_has_key | Checks if there is a key-value in the storage. |
| storage_read | Reads the value stored under the given key. |
| storage_remove | Removes the value stored under the given key.
If key-value existed returns |
| storage_usage | Current total storage usage of this smart contract that this account would be paying for. |
| storage_write | Writes key-value into storage.
If another key-value existed in the storage with the same key it returns |
| take_blockchain_interface | Removes and returns the current low-level blockchain interface accessible through |
| used_gas | The gas that was already burnt during the contract execution (cannot exceed |
| validator_stake | For a given account return its current stake. If the account is not a validator, returns 0. |
| validator_total_stake | Returns the total stake of validators in the current epoch. |
| value_return | Sets the blob of data as the return value of the contract. |