Custom types like structs, enums, and unions are also supported. See Custom Types.
The following primitive types are supported:
Unsigned 32-bit Integer (
Signed 32-bit Integer (
Unsigned 64-bit Integer (
Signed 64-bit Integer (
Symbols are small efficient strings up to 10 characters in length and limited to
_ that are encoded into 64-bit integers.
Symbols are primarily used for function names and other identifiers that are exported in the public API of a contract. They can also be used wherever short strings are needed to keep gas costs down.
Bytes, Strings (
Byte arrays and strings can be passed to contracts and stores using the
For byte arrays of fixed length,
BytesN can be used. For example, contract IDs
are fixed 32-byte byte arrays, and are represented as
Vec is a sequential and indexable growable collection type.
Values are stored in the environment and are available to contract through the functions defined on Vec. Values stored in the Vec are transmitted to the environment as RawVals, and when retrieved from the Vec are transmitted back and converted from RawVal back into their type.
The values in a Vec are not guaranteed to be of any specific type and conversion will fail if they are not of the expected type. Most functions on Vec return a Result due to this.
Map is a ordered key-value dictionary.
The map is ordered by its keys. Iterating a map is stable and always returns the keys and values in order of the keys.
The map is stored in the Host and available to the Guest through the functions defined on Map. Values stored in the Map are transmitted to the Host as RawVals, and when retrieved from the Map are transmitted back and converted from RawVal back into their type.
The keys and values in a Map are not guaranteed to be of type K/V and conversion will fail if they are not. Most functions on Map return a Result due to this.
Maps have at most one entry per key. Setting a value for a key in the map that already has a value for that key replaces the value.
BigInt is an arbitrary sized signed integer.
The value is stored in the Host and available to the Guest through functions on the type. Operations between BigInts are performed inside the Host and do not consume Guest resources such as memory.
Address is union of all the types that can be the invoker of a contract.
Address may be an account ID (
AccountId) or a contract ID (
The Address type is implemented like an enum custom type and is stored as a two element Vec.
Account ID (
Account ID is an identifier for an account.
Most of the time contracts should use the
Address type, which is a
In contracts the ID is opaque and does not expose the identifier to the contract, but the value can be used as a key in maps, or compared with other account identifiers.