Ledgers

ICPay supports verified ICRC ledgers (including ICP). You can fetch the list, get prices, and resolve canister IDs by symbol.

Overview

  • Each ledger provides id, name, symbol, canisterId, decimals, fee, verified, and optional price data.
  • Prices are available when configured; USD conversions are supported via SDK helpers.

Data model

Selected fields exposed by the SDK:

type LedgerPublic = {
  id: string
  name: string
  symbol: string
  canisterId: string
  decimals: number
  logoUrl: string | null
  verified: boolean
  fee: string | null
  currentPrice: number | null
  lastPriceUpdate: string | null
}

Detailed info:

type SdkLedger = {
  id: string
  name: string
  symbol: string
  canisterId: string
  decimals: number
  verified: boolean
  fee: string | null
  network: 'mainnet' | 'testnet'
  description: string | null
  lastBlockIndex: string | null
  coingeckoId: string | null
  currentPrice: number | null
  lastPriceUpdate: string | null
}

Using with SDK

import { Icpay } from '@ic-pay/icpay-sdk'
const icpay = new Icpay({ publishableKey: 'pk_test_xxx' })

const list = await icpay.getVerifiedLedgers()
const idBySymbol = await icpay.getLedgerCanisterIdBySymbol('ICP')
const info = await icpay.getLedgerInfo(idBySymbol)
const withPrices = await icpay.getAllLedgersWithPrices()

// Convert 10 USD to token amount for a ledger
const calc = await icpay.calculateTokenAmountFromUSD({ usdAmount: 10, ledgerSymbol: 'ICP' })

Using with Widget

You can let the widget fetch verified ledgers automatically or supply cryptoOptions yourself.

Widget examples

'use client'
import { useEffect, useRef } from 'react'
import '@ic-pay/icpay-widget'
export default function Page() {
  const ref = useRef<any>(null)
  useEffect(() => {
    if (!ref.current) return
    ref.current.config = {
      publishableKey: process.env.NEXT_PUBLIC_ICPAY_PK,
      amountsUsd: [1,5,10],
      cryptoOptions: [
        { symbol: 'ICP', label: 'ICP', canisterId: 'ryjl3-tyaaa-aaaaa-aaaba-cai' },
        { symbol: 'ckUSDC', label: 'ckUSDC', canisterId: 'xevnm-gaaaa-aaaar-qafnq-cai' },
      ],
    }
  }, [])
  return <icpay-tip-jar ref={ref as any} />
}

Was this page helpful?