#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

#2388 in Magic Beans

Download history 382/week @ 2024-03-10 304/week @ 2024-03-17 431/week @ 2024-03-24 570/week @ 2024-03-31 373/week @ 2024-04-07 139/week @ 2024-04-14 265/week @ 2024-04-21 159/week @ 2024-04-28 1/week @ 2024-05-05 5/week @ 2024-05-12 13/week @ 2024-05-19 8/week @ 2024-05-26 38/week @ 2024-06-02 52/week @ 2024-06-09 33/week @ 2024-06-16 42/week @ 2024-06-23

166 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
~46K SLoC