Skip to main content
This page takes you from nothing to a finished swap on signet, in TypeScript.

Before you start

1. Install

2. List what the maker trades

No keys, no funds. If this prints routes, the SDK and the maker are both reachable.
routes.ts
Each route has a card with its limits (in sats for BTC and L-BTC), its fees, and a hash you pass back when you create a swap, to hold the maker to those terms.

3. Receive L-BTC from a Lightning payment

This is a reverse swap: you pay a Lightning invoice, the maker locks L-BTC for you, and you claim it.
swap.ts
Run it with WALLET_MNEMONIC, LIQUID_ADDRESS, and a fresh SWAP_INDEX set, pay the printed invoice (for example through the Mutinynet faucet), and the script claims the L-BTC once the maker’s lockup confirms. The swap ends in invoice.settled.
This script keeps it short: the index comes from an environment variable, it polls instead of listening on the WebSocket, and it saves nothing but the swap record. A real app keeps a counter of used indexes, saves signed transactions before broadcasting, and handles failed swaps. See Common mistakes.

Next steps

How swaps work

Who pays first, who claims, and what happens if a swap fails.

Pay Lightning from on-chain

The opposite direction, with a refund path.

Swap states

Every status, and what your app does at each one.

Examples

Runnable programs in the SDK repository.