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

no-std concordium-cis2

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

11 stable releases (5 major)

6.1.0 Feb 22, 2024
5.1.0 Oct 18, 2023
4.0.0 Jun 16, 2023
3.1.0 May 8, 2023
1.2.0 Sep 1, 2022

#1774 in Magic Beans

Download history 58/week @ 2024-01-04 134/week @ 2024-01-11 162/week @ 2024-01-18 266/week @ 2024-01-25 47/week @ 2024-02-01 54/week @ 2024-02-08 112/week @ 2024-02-15 460/week @ 2024-02-22 457/week @ 2024-02-29 329/week @ 2024-03-07 252/week @ 2024-03-14 607/week @ 2024-03-21 277/week @ 2024-03-28 506/week @ 2024-04-04 293/week @ 2024-04-11 135/week @ 2024-04-18

1,308 downloads per month

MPL-2.0 license

540KB
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 and u256_amount. The former one is default. When u256_amount feature is enabled the type TokenAmountU256 is defined and implements the IsTokenAmount interface.

Dependencies

~2.5MB
~45K SLoC