All SDK errors are IcpayError with a machine code and message.

import { Icpay, IcpayError } from '@ic-pay/icpay-sdk'

try {
  await icpay.createPayment({ symbol: 'ICP', amount: '1000' })
} catch (e) {
  if (e instanceof IcpayError) {
    if (e.isBalanceError()) {
      // prompt user to add funds
    } else if (e.isNetworkError()) {
      // retry or show offline UI
    }
  }
}

Error reference

CodeCategoryDescriptionWhat to do
WALLET_NOT_CONNECTEDWalletA wallet/principal is required but not connected (e.g., before calling createPayment).Ask the user to connect their wallet; provide an actorProvider and connectedWallet.
WALLET_CONNECTION_FAILEDWalletFailed to connect to the selected wallet provider.Offer retry or let the user pick another provider.
WALLET_DISCONNECTEDWalletWallet was disconnected mid-flow.Reconnect and restart the action.
WALLET_SIGNATURE_REJECTEDWalletUser rejected the signature prompt.Treat as user cancel; allow retry.
WALLET_USER_CANCELLEDWalletUser cancelled the operation.Do not show as an error; allow retry.
WALLET_PROVIDER_NOT_AVAILABLEWalletRequested wallet provider not available in the environment.Hide/disable unavailable providers; suggest alternatives.
UNSUPPORTED_PROVIDERWalletThe provider is not supported by the SDK.Use a supported provider.
NO_PROVIDERS_AVAILABLEWalletNo wallet providers detected.Prompt user to install/enable a wallet.
INSUFFICIENT_BALANCEBalanceUser balance on selected ledger is insufficient for the amount/fee.Ask user to add funds or pick smaller amount.
BALANCE_CHECK_FAILEDBalanceBalance fetch could not complete.Retry; ensure wallet principal and ledger canister ID are correct.
BALANCES_FETCH_FAILEDBalanceFailed to get all balances.Retry or fetch single-ledger balance as a fallback.
SINGLE_BALANCE_FETCH_FAILEDBalanceFailed to get a specific ledger balance.Retry; verify ledger canister ID and connection.
TRANSACTION_FAILEDTransactionGeneric failure sending funds or completing a step.Show message and allow retry; log details.
TRANSACTION_TIMEOUTTransactionTimed out waiting for confirmation.Show pending state and continue polling or allow retry.
TRANSACTION_CANCELLEDTransactionTransaction was cancelled.Treat similar to user-cancel.
TRANSACTION_INVALIDTransactionInvalid transaction parameters or state.Validate inputs; correct configuration or amount.
TRANSACTION_STATUS_FETCH_FAILEDTransactionCould not fetch transaction status.Retry with backoff; ensure canister/network is reachable.
TRANSACTION_SYNC_TRIGGER_FAILEDTransactionFailed to trigger a sync from canister to API DB.Retry later; the background sync may still complete.
SEND_FUNDS_USD_FAILEDTransactionFailed when converting USD to token and sending.Check price availability and retry.
NETWORK_ERRORNetworkNetwork connectivity problem.Retry with backoff; show offline UI.
API_ERRORNetworkServer-side error from API.Retry; if persistent, contact support and log details.
RATE_LIMIT_EXCEEDEDNetworkToo many requests.Back off and retry after delay.
INVALID_CONFIGConfigMisconfigured SDK options.Fix config (e.g., missing actor provider for send calls).
MISSING_PUBLISHABLE_KEYConfigNo publishable key provided for public operations.Provide publishable key.
INVALID_PUBLISHABLE_KEYConfigProvided publishable key is invalid.Verify and replace key.
SECRET_KEY_REQUIREDConfigMethod requires secret key (server-side).Move call to server and provide secretKey.
VALIDATION_ERRORConfigInput validation failed.Correct parameters and retry.
LEDGER_NOT_FOUNDLedgerLedger not found (by canister ID or symbol).Verify canister ID/symbol; use getVerifiedLedgers().
LEDGER_NOT_VERIFIEDLedgerLedger is not verified for usage.Choose a verified ledger.
TOKEN_NOT_SUPPORTEDLedgerToken/ledger not supported.Use a supported ledger.
INVALID_LEDGER_SYMBOLLedgerProvided symbol is invalid.Use a non-empty valid symbol.
LEDGER_SYMBOL_NOT_FOUNDLedgerNo verified ledger matches the symbol.Inspect verified ledgers or correct symbol.
LEDGER_INFO_FETCH_FAILEDLedgerFailed to fetch ledger info.Retry; verify canister ID.
LEDGERS_WITH_PRICES_FETCH_FAILEDLedgerFailed to fetch ledgers with price data.Retry later.
VERIFIED_LEDGERS_FETCH_FAILEDLedgerFailed to fetch verified ledgers.Retry later.
ACCOUNT_NOT_FOUNDAccountAccount not found.Check account context/keys.
ACCOUNT_INACTIVEAccountAccount is inactive.Reactivate or contact support.
ACCOUNT_INFO_FETCH_FAILEDAccountFailed to fetch account info.Retry; verify keys.
ACCOUNT_WALLET_BALANCES_FETCH_FAILEDAccountFailed to fetch account wallet balances.Retry later.
INVALID_USD_AMOUNTPriceUSD amount <= 0 for conversion.Provide a positive amount.
PRICE_NOT_AVAILABLEPriceNo price available for the selected ledger.Pick a priced ledger or try later.
PRICE_CALCULATION_FAILEDPriceFailed to compute token amount from USD.Retry; verify price availability.
TRANSACTION_HISTORY_FETCH_FAILEDHistoryFailed to fetch transactions history.Retry; verify filters.
PAYMENT_HISTORY_FETCH_FAILEDHistoryFailed to fetch payment history.Retry; verify filters.
PAYMENTS_BY_PRINCIPAL_FETCH_FAILEDHistoryFailed to fetch payments by principal.Retry; verify principal and filters.
UNKNOWN_ERRORGenericUnclassified error.Show generic message; log details for diagnosis.

Was this page helpful?