This guide walks you through a complete swap flow from Bitcoin (BTC) to Ethereum USDC using the LeoKit API. We’ll cover all five steps: getting a quote, generating a deposit transaction, signing and broadcasting, saving the transaction hash, and tracking the swap status.Documentation Index
Fetch the complete documentation index at: https://docs.leokit.dev/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The complete swap flow consists of 5 steps:- Get Quote - Request swap rates from multiple protocols
- Generate Deposit - Create an unsigned transaction
- Sign & Broadcast - Sign with wallet and broadcast to blockchain
- Save Transaction - Register the transaction hash with LeoKit
- Track Status - Monitor swap progress until completion
Example: BTC → ETH USDC
Let’s swap 1 BTC (100,000,000 satoshis) to USDC on Ethereum.Step 1: Get Quote
Request quotes from all supported protocols to find the best rate.Save the
quote_id - you’ll need it for all subsequent steps. Quote IDs expire after 15 minutes.Step 2: Generate Deposit Transaction
Create an unsigned transaction using the quote ID and your selected protocol.For Bitcoin transactions, LeoKit returns a PSBT (Partially Signed Bitcoin Transaction) that you’ll sign in the next step.
Step 3: Sign & Broadcast (Client-Side)
Sign the transaction with your wallet and broadcast it to the Bitcoin network.Step 4: Save Transaction Hash
Register the transaction hash with LeoKit to enable status tracking.Step 5: Track Status
Poll the status endpoint to monitor your swap progress.Status Values
| Status | Description |
|---|---|
pending | Transaction broadcasted, waiting for confirmation |
observed | Transaction confirmed on source chain |
inbound_observed | Protocol detected the deposit |
swap_in_progress | Cross-chain swap executing |
outbound_observed | Tokens being sent to destination |
completed | Swap successful, tokens received |
failed | Swap failed (reverted or error) |
Best Practices
Use appropriate polling intervals - Poll every 10-15 seconds. Faster polling won’t speed up the swap.
Save quote_id persistently - Store it in your database to track swaps even after page refreshes.
Handle timeouts gracefully - Cross-chain swaps can take 5-10 minutes. Show progress indicators to users.
Test with small amounts first - Always test new integrations with minimal amounts on testnet/mainnet.
Next Steps
ERC20 Approvals
Learn how to handle token approvals for ERC20 swaps
Error Debugging
Debug failed swaps using trace IDs