Handle Refunds & Failures
Error Codes
Complete reference of all API and SDK error codes with solutions.
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"
}
| Error Code | Description | Solution |
|---|
unauthorized | Missing or invalid authentication | Ensure client is initialized |
invalid_signature | Signature verification failed | Re-initialize wallet |
expired_token | Session expired | Reinitialize client |
| Error Code | Description | Solution |
|---|
insufficient_balance | Not enough BTC in wallet | Add funds to Arkade wallet |
amount_too_low | Below minimum swap amount | Increase swap amount |
amount_too_high | Exceeds maximum swap amount | Reduce swap amount |
invalid_address | Target address invalid | Check address format |
unsupported_token | Token not supported | Use supported token |
unsupported_chain | Chain not supported | Use supported chain |
rate_limit_exceeded | Too many requests | Wait and retry |
service_unavailable | Service temporarily down | Retry later |
| Error Code | Description | Solution |
|---|
swap_not_found | Swap ID doesn't exist | Check swap ID |
swap_expired | Swap timed out | Create new swap |
already_claimed | Funds already claimed | No action needed |
already_refunded | Funds already refunded | No action needed |
locktime_not_expired | Too early to refund | Wait for locktime |
invalid_preimage | Wrong preimage provided | Check preimage |
htlc_not_funded | HTLC not ready yet | Wait for ServerFunded |
| Error Code | Description | Solution |
|---|
network_error | Connection failed | Check internet |
timeout | Request timed out | Retry request |
blockchain_error | On-chain error | Check blockchain status |
arkade_error | Arkade service error | Retry or contact support |
| Error | Description | Solution |
|---|
invalid_mnemonic | Seed phrase is invalid | Check 12/24 word phrase |
storage_unavailable | IndexedDB not accessible | Check browser permissions |
| Error | Description | Solution |
|---|
swap_not_in_storage | Swap not found locally | Use xpub-based recovery |
storage_full | Storage quota exceeded | Clear old swaps |
storage_corrupted | Data corruption | Clear and recover |
The API uses standard HTTP status codes:
| Code | Meaning | Description |
|---|
| 200 | OK | Request successful |
| 201 | Created | Resource created |
| 400 | Bad Request | Invalid parameters |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Action not allowed |
| 404 | Not Found | Resource doesn't exist |
| 409 | Conflict | Resource state conflict |
| 429 | Too Many Requests | Rate limited |
| 500 | Server Error | Internal error |
| 503 | Service Unavailable | Maintenance |
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"
}
}
}
| Error | Quick Fix |
|---|
insufficient_balance | Deposit more BTC to Arkade |
invalid_mnemonic | Check spelling, 12 or 24 words |
swap_not_found | Use xpub-based recovery |
locktime_not_expired | Wait for time shown in swap data |
rate_limit_exceeded | Wait 60 seconds, then retry |
network_error | Check connection, retry |