#token #standard #concordium #events #type #parameters #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 209/week @ 2024-07-28 255/week @ 2024-08-04 142/week @ 2024-08-11 43/week @ 2024-08-18 10/week @ 2024-08-25 59/week @ 2024-09-01 115/week @ 2024-09-08 155/week @ 2024-09-15 106/week @ 2024-09-22 256/week @ 2024-09-29 56/week @ 2024-10-06 52/week @ 2024-10-13 7/week @ 2024-10-20 15/week @ 2024-10-27 124/week @ 2024-11-03 23/week @ 2024-11-10

171 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