Cross Chain Swaps with Bitcoin
Steps to Cross Chain Swap Native BTC
This guide will walk you through using the /quotes and /status endpoints on 0x’s Cross Chain API to:
- Buy BTC: sell a token on an EVM chain and receive native BTC at a Bitcoin address.
- Sell BTC: sell native BTC from a Bitcoin address and receive a token on another chain.
The examples use USDC on Base as the other side of the swap.
Terms
0. Prerequisites
Make sure you have:
- 0x API key
- A mainnet Bitcoin address. Use a P2WPKH address that starts with
bc1qwhen you can. - To buy BTC: a funded EVM wallet, set up as in Get started.
- To sell BTC: BTC at your Bitcoin address in a confirmed UTXO. The amount must cover the sell amount and the miner fee.
- To sell BTC: a WIF in
BITCOIN_WIF. The example uses bitcoinjs-lib,ecpair, andtiny-secp256k1.
Bitcoin values
Use these values in every Bitcoin request:
Write BTC amounts as integers in base units, the same as EVM token amounts. The base unit of BTC is the satoshi. BTC has 8 decimals, so 1 BTC = 100,000,000 satoshis.
Supported Bitcoin address types
The API accepts mainnet addresses of these types:
Buy BTC with a token on an EVM chain
1. Fetch a quote
Set destinationChain to bitcoin and buyToken to the native BTC token.
destinationAddress is required. Without it, the API returns HTTP 400 INPUT_INVALID with the reason Bitcoin destinationAddress is required.
2. Set an allowance and send the transaction
3. Monitor the cross chain execution
Poll /status with the Base transaction hash and the quoteId.
The BTC is at destinationAddress when status is bridge_filled.
Sell BTC for a token on another chain
1. Fetch a quote
Set originChain to bitcoin and sellToken to the native BTC token.
Check these points before you use the quote:
- Do not send
feeBps,feeRecipient, orfeeToken. The API returns HTTP 400 with the reasonFee collection is not supported when origin chain is Bitcoin. allowanceTargetisnull. Bitcoin has no approval step and no wrap step.
Example response
A Bitcoin confirmation takes about 10 minutes.
2. Sign the PSBT
3. Broadcast the transaction
mempool.space returns the txid.
4. Monitor the cross chain execution
Poll /status with originChain set to bitcoin, originTxHash set to the txid, and the quoteId.
For the status lifecycle and failure handling, see Tracking Transaction Status.