Icrc1
A full implementation of the ICRC-1 fungible token standard
Install / Use
/learn @NatLabs/Icrc1README
ICRC-1 Implementation
This repo contains the implementation of the ICRC-1 token standard.
References and other implementations
Documentation
Getting Started
-
Expose the ICRC-1 token functions from your canister
-
Import the
icrc1lib and expose them in anactorclass.Take a look at the examples
-
-
Launch the basic token with all the standard functions for ICRC-1
- Install the mops package manager
- Replace the values enclosed in
< >with your desired values and run in the terminal
git clone https://github.com/NatLabs/icrc1 cd icrc1 mops install 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; })' -
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
Tests
Internal Tests
- Download and Install vessel
- Run
make test - Run
make actor-test
Dfinity's ICRC-1 Reference Tests
- Install Rust and Cargo via rustup
curl https://sh.rustup.rs -sSf | sh
- Then run the
ref-testcommand
make ref-test
Funding
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.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
