This repo contains the implementation of the ICRC-2.
-
Expose the ICRC-1 from your canister
- Import the
icrc1lib and expose them in anactorclass.
git clone https://github.com/JingJingZhang9/I3-code.git dfx start --background --clean dfx deploy icrc1 --argument '( record { name = "<Insert Token Name>"; symbol = "<Insert Symbol>"; decimals = 6; fee = 1_000_000; max_supply = 1_000_000_000_000; initial_balances = vec { record { record { owner = principal "<Insert Principal>"; subaccount = null; }; 100_000_000 } }; min_burn_amount = 10_000; minting_account = null; advanced_settings = null; })'
- Import the
-
Create a token dynamically from a canister
import Nat8 "mo:base/Nat8"; import Token "mo:icrc1/ICRC1/Canisters/Token"; actor{ let decimals = 8; // replace with your chosen number of decimals func add_decimals(n: Nat): Nat{ n * 10 ** decimals }; let pre_mint_account = { owner = Principal.fromText("<Insert Principal>"); subaccount = null; }; let token_canister = Token.Token({ name = "<Insert Token Name>"; symbol = "<Insert Token Symbol>"; decimals = Nat8.fromNat(decimals); fee = add_decimals(1); max_supply = add_decimals(1_000_000); // pre-mint 100,000 tokens for the account initial_balances = [(pre_mint_account, add_decimals(100_000))]; min_burn_amount = add_decimals(10); minting_account = null; // defaults to the canister id of the caller advanced_settings = null; }); }
The fields for the
advanced_settingsrecord are documented here
This library implements the https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md .
ICRC-2 is an extension of the ICRC-1 standard. ICRC-2 provides a way for account owners to delegate token transfer authorization to a third party, allowing the third party to perform transfers on behalf of the owner: icrc2_approve: Authorizes the spender to transfer a certain amount of tokens on behalf of the caller from the account { owner = caller; subaccount = from_subaccount }. The number of transfers the spender can initiate from the caller's account is unlimited as long as the total amounts and fees of these transfers do not exceed the allowance. icrc2_transfer_from: Transfers a certain amount of tokens between two accounts.
- Download and Install vessel
- Run
make test - Run
make actor-test
This library was initially incentivized by ICDevs. You can view more about the bounty on the forum or website. The bounty was funded by The ICDevs.org community and the DFINITY Foundation and the award was paid to @NatLabs. If you use this library and gain value from it, please consider a donation to ICDevs.