Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.dzap.io/llms.txt

Use this file to discover all available pages before exploring further.

Bridging on DZap Core uses the same getTradeQuotes / trade flow as a same-chain swap — you just set toChain to the destination.

End-to-end: USDC Arbitrum → USDC Base

import { DZapClient, ApprovalModes } from '@dzapio/sdk';
import { createWalletClient, http } from 'viem';
import { arbitrum } from 'viem/chains';

const dzap = DZapClient.getInstance();
const walletClient = createWalletClient({ account: '0x...', chain: arbitrum, transport: http() });

const quotes = await dzap.getTradeQuotes({
  fromChain: 42161,
  account: '0x...',
  data: [{
    amount: '10000000',                                          // 10 USDC
    srcToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',     // Arbitrum USDC
    destToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',    // Base USDC
    toChain: 8453,
    slippage: 1,
  }],
});

// Approve (if needed) — same as swap, see /sdk/approvals

const result = await dzap.trade({
  request: {
    fromChain: 42161,
    sender: '0x...',
    refundee: '0x...',
    data: [{
      amount: '10000000',
      srcToken: '0xaf88...',
      destToken: '0x8335...',
      toChain: 8453,
      protocol: quotes[0].protocol,
      recipient: '0xRecipientOnBase',
      slippage: 1,
    }],
  },
  signer: walletClient,
});

Tracking the bridge

Bridges settle asynchronously. Track with getTradeTxnStatus:
// Poll until status is "completed"
const status = await dzap.getTradeTxnStatus({
  txIds: `42161-${result.txnHash}`,
});

console.log(status.status);  // "pending" | "completed" | "failed"
For multiple in-flight bridges, pass a comma-separated txIds and DZap returns a map.

What can go wrong

  • Refunds — if a bridge fails on the destination side, funds are refunded to the refundee address on the source chain. Always set refundee to a wallet you control.
  • Recipient ≠ sender — for cross-chain you can specify a different recipient (the destination address). Useful for paying on behalf of someone else.
  • Slippage on destination — bridges that swap on settlement (e.g. USDC → ETH on the destination side) honor slippage end-to-end.

Choosing a bridge

You don’t — DZap picks. The quote response surfaces which bridge will be used (protocol field). If you have a preference (e.g. “Across only”), filter the quote response client-side and re-call buildTradeTxn with that protocol. For more advanced flows (bridge + LP-deposit, bridge + claim), see DZap Fuse.