[−][src]Crate concordium_contracts_common
This library provides the core API that can be used to write smart contracts for the Concordium blockchain. It aims to provide safe wrappers around the core primitives exposed by the chain and accessible to smart contracts.
By default the library will be linked with the
std crate, the rust standard library,
however to minimize code size this library supports toggling compilation
with the #![no_std]
attribute via the feature std
which is enabled by
default. Compilation without the std
feature requires a nightly version of
rust.
To use this library without the std
feature you have to disable it, which
can be done, for example, as follows.
[dependencies.concordium-contracts-common]
default-features = false
In your project's Cargo.toml
file.
Modules
schema | Types related to contract schemas. These are optional annotations in modules that allow the users of smart contracts to interact with them in a way that is better than constructing raw bytes as parameters. |
Structs
AccountAddress | Address of an account, as raw bytes. |
Amount | The type of amounts on the chain |
ChainMetadata | Chain metadata accessible to both receive and init methods. |
ContractAddress | Address of a contract. |
Cursor | Add offset tracking inside a data structure. |
InitContext | Chain context accessible to the init methods. |
ParseError | Zero-sized type to represent an error when reading bytes and deserializing. |
ReceiveContext | Chain context accessible to the receive methods. |
Enums
Address | Either an address of an account, or contract. |
AmountParseError | An error indicating why parsing of an amount failed. Since amount parsing is typically a user-facing activity this is fairly precise, so we can notify the user why we failed, and what they can do to fix it. |
SeekFrom | This is the equivalent to the
SeekFrom type from
the rust standard library, but reproduced here to avoid dependency on
|
Constants
ACCOUNT_ADDRESS_SIZE | Size of an account address when serialized in binary. NB: This is different from the Base58 representation. |
Traits
Deserial | The |
Get | A more convenient wrapper around |
Read | The |
Seek | The |
Serial | The |
Serialize | The |
Write | The |
Functions
deserial_map_no_length | Read a Map as an list of key-value pairs given some length. NB: This ensures there are no duplicates, hence the specialized type. Moreover this will only succeed if keys are listed in order. |
deserial_map_no_length_no_order_check | Read a Map as an list of key-value pairs given some length.
Slightly faster version of |
deserial_set_no_length | Read a Set as an list of keys, given some length. NB: This ensures there are no duplicates, hence the specialized type. Moreover this will only succeed if keys are listed in order. |
deserial_set_no_length_no_order_check | Read a Set as an list of key-value pairs given some length.
Slightly faster version of |
deserial_vector_no_length | Read a vector given a length. |
from_bytes | Dual to |
serial_map_no_length | Write a Map as a list of key-value pairs ordered by the key, without the length information. |
serial_set_no_length | Write a Set as an list of keys ordered, without the length information. |
serial_vector_no_length | Write a vector without including length information. |
to_bytes | Serialize the given value to a freshly allocated vector of bytes using
the provided |
Type Definitions
BlockHeight | Height of the block. |
FinalizedHeight | Finalized height. In the context of chain metadata this is the height of the block which is explicitly recorded as the last finalized block in the block under consideration. |
ParseResult | A type alias used to indicate that the value is a result
of parsing from binary via the |
SlotNumber | Sequential slot number |
SlotTime | Time at the beginning of the current slot, in miliseconds. |