Lendasat LogoLendasat Docs
Handle Refunds & Failures

Error Codes

Complete reference of all API and SDK error codes with solutions.

Error Handling Overview

Basic error handling pattern:

try {
  const result = await client.createLightningToEvmSwap({
    targetAddress: "0x...",
    targetToken: "usdc_pol",
    targetChain: "polygon",
    sourceAmount: 100000,
  });
} catch (error) {
  console.error("Swap failed:", error.message);
  // Error messages include machine-readable codes like:
  // "insufficient_balance", "amount_too_low", "rate_limit_exceeded"
}

API Error Codes

Authentication & Authorization

Error CodeDescriptionSolution
unauthorizedMissing or invalid authenticationEnsure client is initialized
invalid_signatureSignature verification failedRe-initialize wallet
expired_tokenSession expiredReinitialize client

Swap Creation Errors

Error CodeDescriptionSolution
insufficient_balanceNot enough BTC in walletAdd funds to Arkade wallet
amount_too_lowBelow minimum swap amountIncrease swap amount
amount_too_highExceeds maximum swap amountReduce swap amount
invalid_addressTarget address invalidCheck address format
unsupported_tokenToken not supportedUse supported token
unsupported_chainChain not supportedUse supported chain
rate_limit_exceededToo many requestsWait and retry
service_unavailableService temporarily downRetry later

Swap Execution Errors

Error CodeDescriptionSolution
swap_not_foundSwap ID doesn't existCheck swap ID
swap_expiredSwap timed outCreate new swap
already_claimedFunds already claimedNo action needed
already_refundedFunds already refundedNo action needed
locktime_not_expiredToo early to refundWait for locktime
invalid_preimageWrong preimage providedCheck preimage
htlc_not_fundedHTLC not ready yetWait for ServerFunded

Network Errors

Error CodeDescriptionSolution
network_errorConnection failedCheck internet
timeoutRequest timed outRetry request
blockchain_errorOn-chain errorCheck blockchain status
arkade_errorArkade service errorRetry or contact support

SDK-Specific Errors

Initialization Errors

ErrorDescriptionSolution
invalid_mnemonicSeed phrase is invalidCheck 12/24 word phrase
storage_unavailableIndexedDB not accessibleCheck browser permissions

Storage Errors

ErrorDescriptionSolution
swap_not_in_storageSwap not found locallyUse xpub-based recovery
storage_fullStorage quota exceededClear old swaps
storage_corruptedData corruptionClear and recover

HTTP Status Codes

The API uses standard HTTP status codes:

CodeMeaningDescription
200OKRequest successful
201CreatedResource created
400Bad RequestInvalid parameters
401UnauthorizedAuthentication required
403ForbiddenAction not allowed
404Not FoundResource doesn't exist
409ConflictResource state conflict
429Too Many RequestsRate limited
500Server ErrorInternal error
503Service UnavailableMaintenance

Error Response Format

API errors follow this structure:

// API error response structure
interface ApiError {
  error: {
    code: string; // Machine-readable code
    message: string; // Human-readable message
    details?: object; // Additional context
  };
}

// Example error response
{
  "error": {
    "code": "insufficient_balance",
    "message": "Insufficient balance for swap",
    "details": {
      "required": 100000,
      "available": 50000,
      "currency": "sats"
    }
  }
}

Common Solutions

ErrorQuick Fix
insufficient_balanceDeposit more BTC to Arkade
invalid_mnemonicCheck spelling, 12 or 24 words
swap_not_foundUse xpub-based recovery
locktime_not_expiredWait for time shown in swap data
rate_limit_exceededWait 60 seconds, then retry
network_errorCheck connection, retry