This repository contains a complete implementation of the Internet Computer ICRC token standards (ICRC-1, ICRC-2, ICRC-3, and ICRC-4) written in Motoko. This implementation can be forked and customized to create your own token on the Internet Computer.
- ICRC-1: Basic fungible token functionality (transfers, balances)
- ICRC-2: Token approval and transfer-from capability
- ICRC-3: Transaction history and archiving
- ICRC-4: Batch operations for transfers and balance queries
- DFX SDK (v0.14.0 or newer)
- Mops package manager
- Internet Computer identity for deployment
-
Clone the repository:
git clone https://github.com/Quantum-Leap-Labs-Inc/ICRC-Token.git
-
Navigate and deploy locally for testing:
cd src/token_backend bash runner.sh
To customize the token for your own use:
- Modify the token parameters in
src/token-backend/Token.mo
or in the deployment script. - Key parameters to consider changing:
- Token name
- Token symbol
- Logo (base64 encoded)
- Decimals
- Max supply
- Fee structure
To deploy to the Internet Computer mainnet:
-
Modify the deployment script to include the
--network ic
flag:# Example modification to deploy.sh dfx deploy token --network ic --argument "(...your token config...)"
-
Ensure you have sufficient cycles in your identity's wallet.
-
Run the deployment script:
bash runner.sh
The deployment script requires three different identities:
- Admin Principal: Used to deploy the token canister
- Owner Principal: Used for testing transfers
- Minter Principal: Used for testing other operations
Configure these identities in your deployment script by replacing the placeholder principals with your own.
The token canister implements the standard ICRC interfaces:
icrc1_name()
: Returns the token nameicrc1_symbol()
: Returns the token symbolicrc1_decimals()
: Returns the token decimal placesicrc1_fee()
: Returns the transfer feeicrc1_metadata()
: Returns token metadataicrc1_total_supply()
: Returns total token supplyicrc1_balance_of(account)
: Returns balance of an accounticrc1_transfer(args)
: Transfers tokens between accountsmint(args)
: Mints new tokens (admin only)
icrc2_allowance(args)
: Returns the allowance for a spendericrc2_approve(args)
: Approves a spender to transfer tokensicrc2_transfer_from(args)
: Transfers tokens on behalf of another account
icrc3_get_blocks(args)
: Returns transaction blocksicrc3_get_archives(args)
: Returns archive informationicrc3_get_tip_certificate()
: Returns the latest block certificateicrc3_supported_block_types()
: Returns supported block types
icrc4_transfer_batch(args)
: Performs multiple transfers in one callicrc4_balance_of_batch(args)
: Queries multiple balances in one callicrc4_maximum_update_batch_size()
: Returns max batch size for updatesicrc4_maximum_query_batch_size()
: Returns max batch size for queries
For advanced configuration, the admin can update various parameters after deployment:
admin_update_owner(new_owner)
: Updates the owner principaladmin_update_icrc1(requests)
: Updates ICRC-1 ledger parametersadmin_update_icrc2(requests)
: Updates ICRC-2 ledger parametersadmin_update_icrc4(requests)
: Updates ICRC-4 ledger parameters