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
171 downloads per month
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