Who Funds What
The state machine is direction-agnostic. “Client funds” and “Server funds” refer to different addresses depending on the swap direction.
BTC → EVM (Client sends BTC, receives tokens)
EVM → BTC (Client sends tokens, receives BTC)
Gasless flow (recommended):
Manual flow (with signer):
State Overview
States Explained
Early exit: In the
ClientFunded state, if the server hasn’t funded its side yet, you can refund immediately without waiting for the timelock. The swap transitions to ClientRefunded.Flow Examples
BTC → EVM Success Flow
ClientRedeemed before reaching ServerRedeemed - the server only settles after the client’s claim is confirmed on-chain.
- Client generates secret S, shares hash H with service
- Client sends BTC to
boltz_invoice(Lightning) /btc_vhtlc_address(Arkade) /btc_htlc_address(On-chain) - Payment detected (
ClientFundingSeen), then confirmed (ClientFunded) - Service locks tokens in
evm_htlc_addresson EVM chain (ServerFunded) - Client reveals S, claims tokens from
evm_htlc_addressvia gasless EIP-712 (ClientRedeeming→ClientRedeemed) - Service extracts S from blockchain, claims BTC (
ServerRedeemed)
EVM → BTC Success Flow (Gasless)
- Client creates swap - receives
client_evm_address(SDK-derived deposit address) - Client sends stablecoins to
client_evm_address(not the HTLC!) - SDK calls
fundSwapGasless()- signs Permit2, server relays tokens fromclient_evm_address→evm_htlc_address - Funding detected (
ClientFundingSeen), then confirmed (ClientFunded) - Service sends BTC to client’s Arkade wallet / Lightning invoice / on-chain address (
ServerFunded) - Service reveals preimage (
ClientRedeeming→ClientRedeemed) and claims tokens fromevm_htlc_address(ServerRedeemed)
EVM → BTC Success Flow (Manual / With Signer)
- Client creates swap - receives
evm_htlc_addressand coordinator details - Client approves token spend, then calls
HTLCCoordinator.executeAndCreateWithPermit2()to lock tokens inevm_htlc_address(client pays gas) - Funding detected (
ClientFundingSeen), confirmed (ClientFunded) - Service sends BTC (
ServerFunded) - Service reveals preimage (
ClientRedeeming→ClientRedeemed) and claims tokens fromevm_htlc_address(ServerRedeemed)
Timeout Flow
Late Funding Flow
Expiration Flow
expire_pending_swaps). No funds locked.
Early Exit Flow
Transition Rules
Handling Each Status
Terminal States
These states are final - no further transitions occur:ServerRedeemed- Success (both parties received funds)Expired- No payment was madeClientRefunded- Client exited earlyClientFundedServerRefunded- EVM HTLC timed outClientRefundedServerRefunded- Both sides refundedClientRedeemedAndClientRefunded- Edge case resolved
Best Practices
- Monitor
Pendingswaps - Prompt users to pay before the ~30 minute timeout (default; configurable on the server) - Auto-claim
ServerFunded- Claim immediately when ready - Handle
ClientRedeeming- Show a loading state; claim is in progress - Wait for
ServerRedeemed- This is the true success terminal, notClientRedeemed - Track terminal states - Clean up UI for completed/expired swaps