Crate unc_sdk

Source

Re-exports§

pub use unc_sys as sys;
pub use base64;
pub use borsh;
pub use bs58;
pub use serde;
pub use serde_json;
pub use crate::utils::*;

Modules§

collections
Collections that offer an alternative to standard containers from std::collections::* by utilizing the underlying blockchain trie storage more efficiently.
env
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.
json_types
Helper types for JSON serialization.
store
Collections and types used when interacting with storage.
utils
Helper methods that often used in smart contracts.

Macros§

log
Helper macro to log a message through env::log_str. This macro can be used similar to the std::format macro.
require
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.

Structs§

Abort
A simple type used in conjunction with FunctionError representing that the function should abort without a custom message.
AccountId
Utility Account Identifier.
AccountIdRef
Account identifier. This is the human readable UTF-8 string which is used internally to index accounts on the network and their respective state.
Gas
GasWeight
Weight of unused gas to use with promise_batch_action_function_call_weight.
Promise
A structure representing a result of the scheduled execution on another contract.
PromiseIndex
Promise index that is computed only once.
PublicKey
Public key in a binary format with base58 string serialization with human-readable curve. The key types currently supported are secp256k1 and ed25519.
UncToken

Enums§

Allowance
Allow an access key to spend either an unlimited or limited amount of gas
CurveType
PublicKey curve
PromiseError
All error variants which can occur with promise results.
PromiseOrValue
When the method can return either a promise or a value, it can be called with PromiseOrValue::Promise or PromiseOrValue::Value to specify which one should be returned.
PromiseResult
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.

Traits§

FunctionError
Enables contract runtime to panic with the given type. Any error type used in conjunction with #[handle_result] has to implement this trait.
IntoStorageKey
Converts Self into a Vec<u8> that is used for a storage key through into_storage_key.

Type Aliases§

BlockHeight
Height of the block.
BlockHeightDeltaDeprecated
Block height delta that measures the difference between BlockHeights.
CryptoHash
Raw type for 32 bytes of the hash.
Duration
Raw type for duration in nanoseconds
EpochHeight
Height of the epoch.
GCCountDeprecated
IteratorIndexDeprecated
NonceDeprecated
Nonce for transactions.
NumBlocksDeprecated
Number of blocks in current group.
NumSeatsDeprecated
Number of seats of validators (block producer or hidden ones) in current group (settlement).
NumShardsDeprecated
Number of shards in current group.
PromiseIdDeprecated
ProtocolVersionDeprecated
ReceiptIndexDeprecated
An index of Receipt to append an action
ShardIdDeprecated
Shard index, from 0 to NUM_SHARDS - 1.
StorageUsage
StorageUsage is used to count the amount of storage used by a contract.
StorageUsageChangeDeprecated
StorageUsageChange is used to count the storage usage within a single contract call.
Timestamp
Raw type for timestamp in nanoseconds
ValidatorIdDeprecated
Validator identifier in current group.
ValidatorMaskDeprecated
Mask which validators participated in multi sign.

Attribute Macros§

ext_contract
ext_contract takes a Rust Trait and converts it to a module with static methods. Each of these static methods takes positional arguments defined by the Trait, then the receiver_id, the attached deposit and the amount of gas and returns a new Promise.
unc
This attribute macro is used to enhance the unc_bindgen macro. It is used to add Borsh and Serde derives for serialization and deserialization. It also adds BorshSchema and JsonSchema if needed
unc_bindgen
This attribute macro is used on a struct and its implementations to generate the necessary code to expose pub methods from the contract as well as generating the glue code to be a valid UNC contract.

Derive Macros§

BorshStorageKey
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.
EventMetadata
NOTE: This is an internal implementation for #[unc_bindgen(events(standard = ...))] attribute.
FunctionError
FunctionError generates implementation for unc_sdk::FunctionError trait. It allows contract runtime to panic with the type using its ToString implementation as the message.
PanicOnDefault
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).
UncSchema