icrc-ledger

Deploy and interact with ICRC-1 and ICRC-2 token ledgers on Internet Computer.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/phukrit7171/Relationship-Smart-Contract-ICP --skill icrc-ledger-phukrit7171
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: icrc-ledger
Source: https://github.com/phukrit7171/Relationship-Smart-Contract-ICP/tree/main/.agents/skills/icrc-ledger
Command: npx skills add https://github.com/phukrit7171/Relationship-Smart-Contract-ICP --skill icrc-ledger-phukrit7171

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working with fungible tokens on the Internet Computer requires correct handling of ICRC-1 transfers, ICRC-2 approve/transferFrom allowances, per-ledger fees, and account formats — mistakes like wrong fees, missing approvals, or malformed accounts cause failed transactions that are hard to debug. ## Core Features & Use Cases - Token Transfers and Balances: Query balances and execute ICRC-1 transfers against ICP, ckBTC, and ckETH ledgers with proper error handling for every TransferError variant. - ICRC-2 Allowance Flows: Implement the two-step approve then transferFrom pattern for third-party spending, similar to ERC-20 allowances. - Ledger Deployment: Deploy a local ICRC-1 ledger canister with correct init args, including the requirement that the minting account differs from funded accounts. - Use Case: A developer building a DeFi canister needs to accept ICP deposits and pay out ckBTC; this Skill provides the Motoko and Rust code patterns, canister IDs, and fee handling to do it correctly. ## Quick Start Ask the AI to show how to transfer ICP tokens from a Rust canister using the ICRC-1 ledger with proper fee and error handling.

Frequently Asked Questions about icrc-ledger

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I transfer ICP tokens from a canister?

Call icrc1_transfer on the ICP ledger canister ryjl3-tyaaa-aaaaa-aaaba-cai with a TransferArg containing the destination Account, amount, fee of 10000 e8s, and created_at_time for deduplication. Match on the returned Result to handle InsufficientFunds, BadFee, and other error variants.

How does ICRC-2 approve and transferFrom work on Internet Computer?

ICRC-2 is a two-step flow: the token owner first calls icrc2_approve to grant a spender an allowance, then the spender calls icrc2_transfer_from to move tokens. Calling transferFrom without a prior approve fails with InsufficientAllowance.

What is the difference between ICRC-1 and ICRC-2?

ICRC-1 defines the base fungible token standard with transfers, balances, and metadata. ICRC-2 extends it with approve and transferFrom allowance mechanics, enabling third-party spending similar to ERC-20 on Ethereum.

Why does my ICRC transfer fail with BadFee?

Each ledger sets its own fee and fees can change at runtime, so a hardcoded value may be wrong. Query icrc1_fee for the current value, and note that transfers to or from the minting account are burns or mints requiring fee of zero.

Why does icrc2_approve trap with minting account error?

The ledger rejects approvals from the minting account with the error that the minting account cannot delegate mints. Use a separate principal for minting_account than any principal listed in initial_balances when deploying the ledger.

Can I call the ICRC ledger directly from a frontend?

ICRC-1 transfers should originate from a backend canister rather than directly from the frontend. Frontend-initiated transfers expose users to reentrancy risks and can bypass business logic enforced by the backend.