#token #standard #concordium #events #type #error #cis2

no-std concordium-cis2

A collection of types for implementing CIS-2 Concordium Token Standard

12 stable releases (5 major)

6.2.0 Sep 30, 2024
6.1.0 Feb 22, 2024
6.0.0 Jan 22, 2024
5.1.0 Oct 18, 2023
1.2.0 Sep 1, 2022

#8 in #concordium

Download history 42/week @ 2024-07-01 25/week @ 2024-07-08 99/week @ 2024-07-15 246/week @ 2024-07-22 125/week @ 2024-07-29 251/week @ 2024-08-05 120/week @ 2024-08-12 41/week @ 2024-08-19 9/week @ 2024-08-26 64/week @ 2024-09-02 116/week @ 2024-09-09 158/week @ 2024-09-16 98/week @ 2024-09-23 265/week @ 2024-09-30 47/week @ 2024-10-07 51/week @ 2024-10-14

471 downloads per month

MPL-2.0 license

550KB
9K SLoC

A library that simplifies working with the Concordium Token Standard CIS2 on-chain.

Links:


lib.rs:

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.

Dependencies

~1.8–2.9MB
~55K SLoC