If you are stuck at any part of the implementation, drop a message in our Townhall—our dev team is ready to assist!

What you’ll build
- Network selector: Choose between localnet, testnet, or mainnet environments
- Asset pair selector: Browse and select from all available trading pairs
- Quote dashboard: Get real-time quotes with amount input
- Order dashboard: Create orders, initiate transactions, and track swap status
Quick start
Prerequisites
- Rust and Cargo installed
- Bitcoin and EVM private keys
- Access to Bitcoin and EVM networks (testnet for testing)
Installation
Clone and set up the repository:Configuration
1. Set up environment variables Create a.env file with your private keys:
config.json file contains API endpoints and provider URLs for each network:
Running the application
Start the terminal UI:Application flow
1. Network selection
When you launch the app, you’ll first select your target network. The terminal interface presents all available networks (localnet, testnet, and mainnet) in an interactive list where you can navigate with arrow keys and select with Enter:
src/ui/states/network_selector.rs:
- Navigate with
↑/↓arrow keys - Select with
Enter - Quit with
q - Scrollable list that adapts to terminal size
2. Fetching supported chains and assets
After selecting a network, the app fetches all available chains and their assets from Garden’s API:Response
3. Asset pair selection
The app generates all possible trading pairs and displays them in an interactive scrollable list. Browse through available swap routes showing the source and destination assets with their respective chains:
- Automatic pair generation from chain data
- Scrollable list with visual indicators
- Back navigation to network selection
- Search and filter capabilities
4. Getting quotes
Once you select a pair, enter an amount and press “g” to get a real-time quote. The swap page displays the selected asset pair and allows you to input the amount you want to swap:

5. Creating orders
After confirming the quote, the application creates an order on Garden’s orderbook. You’ll see the order being processed with all the swap details:

6. Initiating transactions
The initiation process differs based on the source chain. After creating an order and approving tokens (for EVM), you’ll see the initiation screen with transaction details ready to be signed and broadcast:
Bitcoin Initiation
For Bitcoin swaps, construct and broadcast a transaction to the HTLC address:EVM Initiation
For EVM chains, sign EIP-712 typed data and submit to the relayer:7. Tracking order status
Monitor your swap progress in real-time. The order status screen displays detailed information about your swap including transaction hashes, swap amounts, and the current state:
- Current order status (Created, Initiated, Awaiting Redeem, Redeemed)
- Swap amounts and asset details
- Real-time status updates

- Created - Order submitted to orderbook
- Initiate Detected - User’s deposit transaction detected
- Initiated - Deposit confirmed on source chain
- Awaiting Redeem - Solver has filled on destination chain
- Redeem Detected - Redemption transaction detected
- Redeemed - Swap completed successfully
src/service/garden/status.rs) implements the complete logic:
Key implementation details
Bitcoin HTLC construction
The app includes a complete Bitcoin HTLC handler (src/service/blockchain/bitcoin/htlc_handler.rs) that:
- Fetches UTXOs from Bitcoin indexers
- Constructs P2WPKH transactions
- Signs with Schnorr signatures
- Broadcasts to the network
- Handles Taproot script paths
EIP-712 signing
For EVM chains, the app uses Alloy to sign typed data:TUI architecture
The terminal UI is built withratatui and follows a state machine pattern:
State trait:
API reference
The app demonstrates usage of Garden’s V2 API:| Endpoint | Purpose |
|---|---|
GET /v2/chains | Fetch all supported chains and assets |
GET /v2/quote | Get real-time swap quotes |
POST /v2/orders | Create a new swap order |
POST /v2/orders/{id}?action=initiate | Submit EVM initiation signature |
GET /v2/orders/{id} | Check order status |
garden-app-idheader for authenticationaccept: application/jsonheader- Proper error handling with
anyhow::Result
You now have a complete reference implementation for building cross-chain swap applications using Garden’s V2 API!
Next steps
By exploring this cookbook, you’ve seen how to build a production-ready swap application. Consider extending it with:- Multi-order management to track multiple swaps simultaneously
- Web interface using the same backend logic
- Advanced Bitcoin features like RBF and CPFP
- Order history persistence with a database
- Affiliate fee integration for monetization