Expand description
This library provides types and functions for working with the Concordium Token Standard CIS2.
It contains types for the parameters for each of the contract functions and types for each event. Each type have implemented serialization according to CIS2. Additionally the crate exports an CIS2Error wrapper type which can be used to wrap and extend a custom error type. This will ensure the CIS2 errors have the correct error codes.
§Example using TransferParams
ⓘ
type TransferParameter = TransferParams<TokenIdVec>;
#[receive(contract = "MyTokenContract", name = "transfer", parameter = "TransferParameter", enable_logger)]
fn contract_transfer<A: HasActions>(
ctx: &impl HasReceiveContext,
logger: &mut impl HasLogger,
state: &mut State,
) -> ContractResult<A> {
// Parse the parameter.
let TransferParams(transfers) = ctx.parameter_cursor().get()?;
// ...
Ok(A::accept())
}
§Features
This crate has features std
, u256_amount
, and serde
. The first one is
default. When the u256_amount
feature is enabled the type
TokenAmountU256
is defined and implements the IsTokenAmount
interface. The serde
features derives serde::Serialize
and
serde::Deserialize
for a variety of types.
Structs§
- Additional information to include with a transfer.
- A query for the balance of a given address for a given token.
- The parameter type for the contract function
balanceOf
. - The response which is sent back when calling the contract function
balanceOf
. It consists of the list of results corresponding to the list of queries. - An untagged event of some amount of a token type being burned. For a tagged version, use
Cis2Event
. - Client for interacting with CIS2 compliant contracts.
- String is not a valid standard identifier. Ensure the length is less than 256 and it only contains ASCII characters.
- The location of the metadata and an optional hash of the content.
- An untagged event of tokens being minted, could be a new token type or extending the total supply of existing token. For a tagged version, use
Cis2Event
. - Specific parameter type for a contract function which receives CIS2 tokens with a specific type D for the AdditionalData.
- Generic parameter type for a contract function which receives CIS2 tokens.
- A query for the operator of a given address for a given token.
- The parameter type for the contract function
operatorOf
. - The response which is sent back when calling the contract function
operatorOf
. It consists of the list of result in the same order and length as the queries in the parameter. - Identifier for a smart contract standard. Consists of a string of ASCII characters up to a length of 255.
- Owned identifier for a smart contract standard. Consists of a string of ASCII characters up to a length of 255.
- The parameter type for the contract function
supports
. - The response which is sent back when calling the contract function
supports
. It consists of a list of results corresponding to the list of queries. - Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- Token Identifier, which combined with the address of the contract instance, forms the unique identifier of a token type.
- An untagged event for setting the metadata for a token. For a tagged version, use
Cis2Event
. - The parameter type for the contract function
tokenMetadata
. - The response which is sent back when calling the contract function
tokenMetadata
. It consists of the list of results corresponding to the list of queries. - A single transfer of some amount of a token.
- An untagged event of a transfer of some amount of tokens from one address to another. For a tagged version, use
Cis2Event
. - The parameter type for the contract function
transfer
. - A single update of an operator.
- An untagged event of an update to an operator address for an owner address. For a tagged version, use
Cis2Event
. - The parameter type for the contract function
updateOperator
.
Enums§
- Errors which can be returned by the
Cis2Client
. - The different errors the contract can produce.
- Tagged CIS2 event to be serialized for the event log.
- The update to an the operator.
- The receiving address for a transfer, similar to the Address type, but contains extra information when the receiver address is a contract.
- The query result type for whether a smart contract supports a standard.
Constants§
- Tag for the CIS2 Burn event.
- The standard identifier for the CIS-0: Standard Detection.
- The standard identifier for the CIS-1: Concordium Token Standard.
- The standard identifier for the CIS-2: Concordium Token Standard 2.
- Tag for the CIS2 Mint event.
- Tag for the CIS2 TokenMetadata event.
- Tag for the CIS2 Transfer event.
- Tag for the CIS2 UpdateOperator event.
Traits§
- Trait for marking types as CIS2 token amounts. For a type to be a valid CIS2 token amount it must implement SchemaType and Serialize, using the LEB128 unsigned integer encoding constrained to at most 37 bytes.
- Trait for marking types as CIS2 token IDs. For a type to be a valid CIS2 token ID it must implement
SchemaType
andSerialize
, such that the first byte indicates how many bytes is used to represent the token ID, followed by this many bytes for the token ID.