Overview
The Token Plugin supports:- ICP Operations: Native ICP token transfers and balance queries
- ICRC-1 Standard: Fungible token transfers and metadata
- ICRC-2 Standard: Approve and transferFrom operations
- Account Management: Principal and subaccount handling
- Transaction Utilities: Amount parsing, formatting, and validation
ICP Operations
getBalance(account?)
Get ICP balance for the current identity or a specific account.
Parameters:
account(optional):string- Account identifier (defaults to current identity)
Promise<bigint> - Balance in e8s (1 ICP = 100,000,000 e8s)
Example:
transfer(to, amount, options?)
Transfer ICP tokens.
Parameters:
to:string- Recipient account identifieramount:bigint | number | string- Amount to transferoptions(optional):ITransferOptionsmemo:bigint- Transaction memofee:bigint- Custom fee (optional)fromSubaccount:Uint8Array- Source subaccount
Promise<ITransferResult>
blockHeight:bigint- Block height of the transaction
queryBlocks(start, length)
Query ICP ledger blocks.
Parameters:
start:bigint- Starting block heightlength:bigint- Number of blocks to query
Promise<unknown> - Block data
ICRC-1 Operations
icrc1Balance(canisterId, account?)
Get ICRC-1 token balance.
Parameters:
canisterId:string- Token canister IDaccount(optional):string | IAccount- Account to query (defaults to current identity)
Promise<bigint> - Token balance
Example:
icrc1Transfer(canisterId, to, amount, options?)
Transfer ICRC-1 tokens.
Parameters:
canisterId:string- Token canister IDto:string | IAccount- Recipient accountamount:bigint | number | string- Amount to transferoptions(optional):Partial<ITransferOptions>
Promise<ITransferResult>
Example:
ICRC-2 Operations
icrc1Approve(canisterId, spender, amount, options?)
Approve a spender to use tokens on your behalf.
Parameters:
canisterId:string- Token canister IDspender:string | IAccount- Spender accountamount:bigint | number | string- Amount to approveoptions(optional):Partial<IApproveArgs>
Promise<bigint> - Approval transaction ID
Example:
icrc1Allowance(canisterId, owner, spender)
Check allowance between owner and spender.
Parameters:
canisterId:string- Token canister IDowner:string | IAccount- Token ownerspender:string | IAccount- Approved spender
Promise<IAllowance>
allowance:bigint- Approved amountexpires_at:bigint[]- Expiration time (optional)
Account Utilities
getAccountId(principal?, subaccount?)
Get ICP account identifier.
Parameters:
principal(optional):string | Principal- Principal (defaults to current identity)subaccount(optional):Uint8Array- Subaccount bytes
string - Account identifier
Example:
createAccount(principal, subaccount?)
Create an account object.
Parameters:
principal:string | Principal- Account owner principalsubaccount(optional):Uint8Array- Subaccount bytes
IAccount
owner:Principal- Account ownersubaccount:Uint8Array- Subaccount
generateSubaccount()
Generate a random subaccount.
Returns: Uint8Array - 32-byte subaccount
Example:
validateAccount(account)
Validate an account identifier.
Parameters:
account:string- Account identifier to validate
boolean - Whether account is valid
Transaction Utilities
parseAmount(amount, decimals?)
Parse amount string to bigint.
Parameters:
amount:string- Amount as string (e.g., “1.5”)decimals(optional):number- Token decimals (default: 8)
bigint - Parsed amount
Example:
formatAmount(amount, decimals?)
Format bigint amount to string.
Parameters:
amount:bigint- Amount in smallest unitsdecimals(optional):number- Token decimals (default: 8)
string - Formatted amount
Example:
createMemo(input)
Create a transaction memo.
Parameters:
input:string | number | bigint- Memo input
bigint - Memo as bigint
Example:
estimateFee(canisterId?, priority?)
Estimate transaction fee.
Parameters:
canisterId(optional):string- Token canister ID (for ICRC tokens)priority(optional):boolean- Priority transaction
Promise<IFeeEstimate>
amount:bigint- Estimated feecurrency:string- Fee currency
Metadata Operations
getTokenMetadata(canisterId?)
Get token metadata.
Parameters:
canisterId(optional):string- Token canister ID (omit for ICP)
Promise<ITokenMetadata>
name:string- Token namesymbol:string- Token symboldecimals:number- Token decimalsfee:bigint- Transfer feetotalSupply:bigint- Total supply (if available)
getSupportedStandards(canisterId)
Get supported token standards.
Parameters:
canisterId:string- Token canister ID
Promise<string[]> - Supported standards
Example: