Skip to main content
Swap & Bridge
In a nutshell
Blockradar’s Swap API lets you exchange assets on the same chain (swap) or move assets between different chains (bridge) using a single unified endpoint.

Prerequisites

Before using the Swap API, ensure you have:
1

API Key

Get your API key from the Blockradar Dashboard. Navigate to Developers to generate one.
2

Wallet Created

Create a wallet via the Create Wallet API or dashboard. You’ll need the walletId for swap operations.
3

Asset IDs

Get the assetId for your source and destination assets from Assets in the dashboard or via the Get Assets API.
4

Sufficient Balance

Ensure your wallet has enough balance of the source asset to cover the swap amount plus network fees.

How It Works

Blockradar automatically determines whether your transaction is a swap or a bridge based on your asset selection:

Swap

Exchange different assets on the same blockchain.Example: USDC → USDT on Base

Bridge

Move assets between different blockchains.Example: USDC on BSC → USDC on Optimism
You don’t need to specify whether it’s a swap or bridge—the API handles this automatically based on the fromAssetId and toAssetId you provide.

Supported Assets & Chains

The Swap API supports major stablecoins across Blockradar-supported chains:
Asset availability varies by chain. Always use the Get Assets API to fetch the current list of supported assets and their assetId values for your target chains.
See Integrations for the complete list of supported networks and stablecoins.

Master Wallet vs Child Address

The Swap API is available at two levels:

Master Wallet

Execute swaps directly from your master wallet. Ideal for treasury operations.

Child Address

Execute swaps from individual child addresses. Perfect for user-specific operations.

Endpoints

Step 1: Get a Quote

Always fetch a quote before executing a swap to show users the expected outcome.

Request Parameters

Quote Example

Quote Response

Understanding Quote Fields

Always display at minimum: amount to receive, estimated arrival time, and fees before the user confirms the swap.

Step 2: Execute the Swap

Once the user confirms the quote, execute the swap.

Request Parameters

Execute Example

Execute Response

Swap operations are asynchronous. The initial response shows PENDING status. Listen for the swap.success or swap.failed webhook to confirm completion.

Order Types

Choose the right order type based on your use case:

Webhook Events

Monitor swap completion through webhooks:

Webhook Payload

Complete Flow Example

Here’s a full implementation showing the quote → confirm → execute flow:

Error Responses

Best Practices

User Experience

  • Always show quotes: Display amount, fees, and estimated time before execution
  • Handle slippage: Inform users about potential price variations
  • Show progress: Use webhooks to update users on swap status

Security

  • Validate amounts: Ensure swap amounts are within acceptable ranges
  • Use references: Track swaps with unique reference IDs
  • Monitor webhooks: Always verify swap completion via webhooks

Performance

  • Cache asset IDs: Store asset IDs locally to avoid repeated lookups
  • Use appropriate order types: Choose FASTEST for time-sensitive, CHEAPEST for cost-sensitive
  • Implement retries: Handle transient failures with exponential backoff

API Reference

Support

The Swap API provides a unified interface for both same-chain swaps and cross-chain bridges. Start with small test amounts on testnets before moving to production.