Get started
The 0x Cross-Chain API is in private beta. Request access to start building.
Quick link with examples: 0x-examples
About 0x Cross Chain API
The 0x Cross Chain API is a fast, flexible API that lets developers programmatically access tokens across various blockchains, enabling cross-chain swap functionality in any app or wallet.
Whether you’re building a new application, or expanding the offering of your existing product, this API helps you integrate cross-chain token swaps with minimal overhead and maximum efficiency.
Steps to Cross Chain Swap Tokens
This guide will walk you through using the /quotes and /status endpoints on 0x’s Cross Chain API to:
- Fetch a quote
- Set allowance
- Sign and send a transaction
- Monitor the status of the cross chain swap
In our example, we will be swapping WETH on Base to USDC on Arbitrum.
0. Prerequisites
Make sure you have:
- A funded Base wallet
- 0x API key
- An RPC Connection (see details below)
Setting up wallet and RPC connection
Base provides a default public RPC endpoint, but for production use, it’s strongly recommended to run your own or use a third-party provider like QuickNode or Alchemy.
To interact with that RPC, we will use a popular TS library, viem.
1. Fetch a Quote
Start by sending a GET request to the 0x /quotes endpoint to get a quote for a specific tokens and chains pair with selected amount.
Example response
2. Set a token allowance
It is possible, that you will need to set proper token allowance to 0x’s AllowanceHolder contract. In cases where allowance will be needed, it will be reported in issues in the response and will be the same as the allowance target for Swap API (when using AllowanceHolder flow). It may differ across chains, so always use the value from the response rather than hardcoding an address.
Below you can find an example on how to set proper token allowance for received quote.
Important: Only EVM chains require token allowances. Solana and Tron do not need an approval step and allowanceTarget will be null for those chains. Native tokens (ETH, BNB, etc.) also do not need approvals.
3. Sign and submit a transaction
Now that we have both the approval and the quote, we can construct, sign, and submit the transaction. Optionally, after the approval, you might want to re-fetch a fresh quote.
Code below will construct, sign, and submit the transaction based on the quote response.
4. Monitor the cross chain execution
The last step is to monitor the execution of the cross chain transaction, including the fill on the destination chain. For that, we will use the /status endpoint.
In your application, you might need to monitor the status repeatedly, as bridging operation might take several seconds or minutes to complete.
It is a good practice to always pass quoteId when polling /status. Without it, bundled transactions (e.g. with ERC-4337) cannot be disambiguated, and the first status request will be slower.
For full status lifecycle details, polling intervals, and failure handling, see Tracking Transaction Status and Handling Failures and Recovery.
Example response
Want to collect fees? See Monetize Your App to learn how to add integrator fees to cross-chain swaps.