API Reference
Errors

Error Codes

Complete reference for error codes returned by the Veridex SDK and Relayer.

SDK Errors

Authentication Errors

CodeMessageCauseSolution
PASSKEY_NOT_SUPPORTEDWebAuthn is not supportedBrowser/device doesn't support passkeysUse a supported browser (Chrome 67+, Safari 14+)
USER_CANCELLEDUser cancelled the operationUser dismissed biometric promptPrompt user to try again
CREDENTIAL_NOT_FOUNDNo stored credential foundUser hasn't registered or credential clearedCall passkey.register()
INVALID_CREDENTIALCredential is invalidCorrupted or expired credentialClear and re-register
SECURITY_ERRORSecurity context requiredNot running on HTTPSUse HTTPS or localhost

Transaction Errors

CodeMessageCauseSolution
INSUFFICIENT_BALANCEInsufficient balanceVault doesn't have enough tokensCheck balance before transfer
INVALID_RECIPIENTInvalid recipient addressMalformed addressValidate address format
INVALID_AMOUNTInvalid amountZero, negative, or malformed amountUse positive bigint
INVALID_TOKENToken not supportedUnknown token addressUse supported token
NONCE_MISMATCHNonce mismatchTransaction already processed or out of orderRefresh and retry

Session Errors

CodeMessageCauseSolution
SESSION_EXISTSSession already activeTried to create while session existsRevoke existing session first
SESSION_EXPIREDSession has expiredSession exceeded durationCreate new session
SESSION_LIMIT_EXCEEDEDSession limit exceededTransfer exceeds session's maxValueCreate session with higher limit
SESSION_TOKEN_NOT_ALLOWEDToken not allowedToken not in session's allowedTokensUse allowed token or create new session
SESSION_RECIPIENT_NOT_ALLOWEDRecipient not allowedRecipient not in allowedRecipientsUse allowed recipient or create new session

Spending Limit Errors

CodeMessageCauseSolution
SPENDING_LIMIT_EXCEEDEDSpending limit exceededTransfer exceeds configured limitWait for reset or adjust limits
DAILY_LIMIT_EXCEEDEDDaily limit exceeded24-hour limit reachedWait for reset
PER_TX_LIMIT_EXCEEDEDPer-transaction limit exceededSingle transfer too largeSplit into smaller transfers

Chain Errors

CodeMessageCauseSolution
UNSUPPORTED_CHAINChain not supportedChain not in SDK configurationUse supported chain
CHAIN_UNAVAILABLEChain unavailableRPC not respondingTry again or use different RPC
RPC_ERRORRPC request failedNetwork or RPC issuesRetry with backoff

Relayer Errors

Submission Errors

CodeHTTPMessageCauseSolution
INVALID_SIGNATURE400Signature verification failedWebAuthn signature invalidEnsure correct payload signing
INVALID_PAYLOAD400Invalid request payloadMalformed JSON or missing fieldsCheck request format
UNSUPPORTED_ACTION400Action not supportedUnknown action typeUse valid action
VAULT_NOT_FOUND400Vault doesn't existVault not deployed on target chainCreate vault first

Rate Limiting

CodeHTTPMessageCauseSolution
RATE_LIMITED429Too many requestsExceeded rate limitWait and retry with exponential backoff
VAULT_RATE_LIMITED429Vault rate limitedToo many requests from vaultWait 60 seconds

Relay Errors

CodeHTTPMessageCauseSolution
RELAY_FAILED500Relay transaction failedOn-chain execution failedCheck error details, may need more gas
RELAYER_ERROR500Internal relayer errorRelayer service issueRetry or contact support
INSUFFICIENT_RELAYER_BALANCE503Relayer out of fundsRelayer needs refundingUse different relayer or wait

Wormhole Errors

CodeHTTPMessageCauseSolution
VAA_NOT_FOUND404VAA not yet availableGuardians haven't attestedWait and retry (~60s)
VAA_EXPIRED400VAA has expiredVAA too oldRe-initiate transaction
INVALID_VAA400Invalid VAAMalformed or tampered VAARe-initiate transaction
WORMHOLE_UNAVAILABLE503Wormhole service unavailableGuardian network issuesWait and retry

Handling Errors

JavaScript/TypeScript

import { createSDK } from '@veridex/sdk';
 
const sdk = createSDK('base', { network: 'testnet' });
 
try {
  await sdk.transferViaRelayer({
    token: USDC,
    recipient: '0x...',
    amount: parseUnits('100', 6),
  });
} catch (error) {
  switch (error.code) {
    case 'INSUFFICIENT_BALANCE':
      showToast('Not enough tokens in your wallet');
      break;
    
    case 'SPENDING_LIMIT_EXCEEDED':
      showToast(`Limit exceeded. Available: ${error.available}`);
      break;
    
    case 'SESSION_EXPIRED':
      // Prompt to create new session
      await sdk.sessions.create({ duration: 3600 });
      // Retry transfer
      break;
    
    case 'RATE_LIMITED':
      // Wait and retry
      await sleep(error.retryAfter * 1000);
      // Retry transfer
      break;
    
    case 'RELAYER_UNAVAILABLE':
      showToast('Service temporarily unavailable. Please try again.');
      break;
    
    default:
      console.error('Unexpected error:', error);
      showToast('Something went wrong. Please try again.');
  }
}

React Error Boundary

import { Component, ReactNode } from 'react';
 
interface Props {
  children: ReactNode;
  fallback: ReactNode;
}
 
interface State {
  hasError: boolean;
  error?: Error;
}
 
class VeridexErrorBoundary extends Component<Props, State> {
  state: State = { hasError: false };
 
  static getDerivedStateFromError(error: Error): State {
    return { hasError: true, error };
  }
 
  render() {
    if (this.state.hasError) {
      const code = (this.state.error as any)?.code;
      
      if (code === 'PASSKEY_NOT_SUPPORTED') {
        return <div>Your browser doesn't support passkeys.</div>;
      }
      
      return this.props.fallback;
    }
 
    return this.props.children;
  }
}

Agent SDK Errors

The Agent SDK (@veridex/agentic-payments) has its own error class and codes:

import { AgentPaymentError, AgentPaymentErrorCode } from '@veridex/agentic-payments';
CodeDescriptionRetryable
LIMIT_EXCEEDEDTransaction exceeds daily or per-tx spending limitNo
INSUFFICIENT_BALANCENot enough tokens in session walletNo
SESSION_EXPIREDSession key has expiredNo
CHAIN_NOT_SUPPORTEDChain ID not in allowedChainsNo
TOKEN_NOT_SUPPORTEDToken not available on target chainNo
NETWORK_ERRORNetwork or RPC failureYes
X402_PAYMENT_FAILEDx402 payment negotiation failedYes
SIGNATURE_FAILEDTransaction signing failedNo

Handling Agent SDK Errors

try {
  await agent.pay({ chain: 10004, token: 'USDC', amount: '100000000', recipient: '0x...' });
} catch (error) {
  if (error instanceof AgentPaymentError) {
    console.log('Code:', error.code);
    console.log('Message:', error.message);
    console.log('Retryable:', error.retryable);
    console.log('Suggestion:', error.suggestion);
 
    switch (error.code) {
      case AgentPaymentErrorCode.LIMIT_EXCEEDED:
        console.log('Over budget — wait for daily reset');
        break;
      case AgentPaymentErrorCode.INSUFFICIENT_BALANCE:
        console.log('Need more tokens:', error.suggestion);
        break;
      case AgentPaymentErrorCode.SESSION_EXPIRED:
        console.log('Re-initialize agent wallet');
        break;
      case AgentPaymentErrorCode.NETWORK_ERROR:
        if (error.retryable) {
          console.log('Retrying...');
        }
        break;
    }
  }
}

Stacks-Specific Errors

CodeDescriptionCause
STACKS_SPONSORSHIP_LIMITSponsorship rate limit exceededToo many sponsored txs per hour
STACKS_POST_CONDITION_FAILPost-condition validation failedTransaction would transfer more than allowed
STACKS_NONCE_ERRORNonce mismatch on StacksConcurrent transaction submission
STACKS_CONTRACT_ERRORClarity contract execution errorInvalid arguments or state

Error Response Format

All errors follow this format:

Core SDK

interface VeridexError extends Error {
  code: string;           // Machine-readable error code
  message: string;        // Human-readable message
  details?: {             // Additional context
    [key: string]: any;
  };
  retryAfter?: number;    // Seconds to wait (for rate limits)
  httpStatus?: number;    // HTTP status code (relayer errors)
}

Agent SDK

interface AgentPaymentError extends Error {
  code: AgentPaymentErrorCode;  // Typed error code enum
  message: string;              // Human-readable message
  retryable: boolean;           // Whether the operation can be retried
  suggestion?: string;          // Suggested action for the user/agent
}

Example (Core SDK):

{
  "code": "SPENDING_LIMIT_EXCEEDED",
  "message": "Transfer exceeds daily spending limit",
  "details": {
    "limitType": "daily",
    "limit": "1000000000000000000",
    "attempted": "2000000000000000000",
    "available": "500000000000000000",
    "resetsAt": 1704153600
  }
}

Example (Agent SDK):

{
  "code": "LIMIT_EXCEEDED",
  "message": "Transaction of $150.00 exceeds daily limit of $100.00",
  "retryable": false,
  "suggestion": "Reduce amount to $75.00 or wait for daily reset at 2026-02-15T00:00:00Z"
}