@kagamidigital/salt-sdk-mirror
    Preparing search index...

    Class InsufficientFunds

    Thrown when a transaction cannot proceed because the account lacks enough native currency to cover its total cost (gas * fee + value) on the destination chain. Mirrors viem's InsufficientFundsError and the Salt API's INSUFFICIENT_FUNDS code — the shortfall may be the gas, the transfer value, or both.

    The transaction is paid for by the account itself (its SaltAccount.publicKey), not by the signer — the signer only coordinates signing off-chain. To check funding ahead of time, read the account's balance directly with the same viem PublicClient passed to submitTx.

    Subclasses SaltCeremonyError, so existing err instanceof SaltCeremonyError handlers keep catching it; use err instanceof InsufficientFunds to handle this case specifically.

    import { Salt, InsufficientFunds } from 'salt-sdk';
    import { parseEther, formatEther } from 'viem';

    const account = await salt.getAccount('account-id');

    // Optional pre-check: the account pays, on the destination chain
    const balance = await publicClient.getBalance({ address: account.publicKey });
    if (balance < parseEther('0.11')) { // value + gas headroom
    console.warn('Account may not afford this tx:', formatEther(balance));
    }

    try {
    const tx = await salt.submitTx({
    accountId: account.id,
    to: '0xRecipientAddress',
    value: parseEther('0.1'),
    chainId: 11155111,
    userAddress: signerAddress,
    walletClient,
    publicClient,
    });
    await tx.wait();
    } catch (err) {
    if (err instanceof InsufficientFunds) {
    console.error(
    `Fund ${err.details.accountAddress ?? 'the account'} on chain ${err.details.chainId}`
    );
    } else {
    throw err;
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cause?: Error
    data?: unknown

    Optional structured data attached to the failure (e.g. on-chain receipt).

    Where and for whom funds are missing.

    message: string
    name: string
    stack?: string