Re-exports

pub use crate::utils::*;

Modules

Collections that offer an alternative to standard containers from std::collections::* by utilizing the underlying blockchain trie storage more efficiently.

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.

Helper types for JSON serialization.

Mock blockchain utilities. These can only be used inside tests and are not available for a wasm32 target.

Macros

Helper macro to log a message through env::log_str. This macro can be used similar to the std::format macro in most cases.

metadata generates the metadata method and should be placed at the very end of the lib.rs file.

Helper macro to create assertions that will panic through the runtime host functions.

setup_allocDeprecated

Deprecated helper function which used to generate code to initialize the GlobalAllocator. This is now initialized by default. Disable wee_alloc feature to configure manually.

Initializes a testing environment to mock interactions which would otherwise go through a validator node. This macro will initialize or overwrite the MockedBlockchain instance for interactions from a smart contract.

Structs

Account identifier. This is the human readable utf8 string which is used internally to index accounts on the network and their respective state.

Represents the amount of NEAR tokens in “gas units” which are used to fund transactions.

Metadata of the contract.

Metadata of a single method.

Mocked blockchain that can be used in the tests for the smart contracts. It implements BlockchainInterface by redirecting calls to VMLogic. It unwraps errors of VMLogic to cause panic during the unit tests similarly to how errors of VMLogic would cause the termination of guest program execution. Unit tests can even assert the expected error message.

A structure representing a result of the scheduled execution on another contract.

Public key in a binary format with base58 string serialization with human-readable curve. The key types currently supported are secp256k1 and ed25519.

Context for the contract execution.

Enums

PublicKey curve

All error variants which can occur with promise results.

When there is a callback attached to one or more contract calls the execution results of these calls are available to the contract invoked through the callback.

When there is a callback attached to one or more contract calls the execution results of these calls are available to the contract invoked through the callback.

Constants

Balance of one NEAR, which is 10^24 Yocto NEAR.

Balance of one Yocto NEAR, which is the smallest denomination. This value is 10^-24 of one NEAR.

Traits

Converts a Borsh serializable object into a Vec<u8> that is used for a storage key.

Converts Self into a Vec<u8> that is used for a storage key through into_storage_key.

Type Definitions

Balance is a type for storing amounts of tokens, specified in yoctoNEAR.

Height of the block.

Block height delta that measures the difference between BlockHeights.

Raw type for 32 bytes of the hash.

Raw type for duration in nanoseconds

Height of the epoch.

Hash used by a struct implementing the Merkle tree.

Nonce for transactions.

Number of blocks in current group.

Number of seats of validators (block producer or hidden ones) in current group (settlement).

Number of shards in current group.

Shard index, from 0 to NUM_SHARDS - 1.

StorageUsage is used to count the amount of storage used by a contract.

StorageUsageChange is used to count the storage usage within a single contract call.

Raw type for timestamp in nanoseconds

Validator identifier in current group.

Mask which validators participated in multi sign.

Attribute Macros

callback is a marker attribute it does not generate code by itself.

callback_args_vec is a marker attribute it does not generate code by itself.

init is a marker attribute it does not generate code by itself.

result_serializer is a marker attribute it does not generate code by itself.

serializer is a marker attribute it does not generate code by itself.

Derive Macros

BorshStorageKey generates implementation for BorshIntoStorageKey trait. It allows the type to be passed as a unique prefix for persistent collections. The type should also implement or derive BorshSerialize trait.

PanicOnDefault generates implementation for Default trait that panics with the following message The contract is not initialized when default() is called. This is a helpful macro in case the contract is required to be initialized with either init or init(ignore_state).