BETA — mainnet live (chain 482120); features are still being finished. Transparency →
Bitcoin Swap BETA Chain 482120
Developers · Guides

Test on a chain fork

Run a copy of the live chain locally with anvil and test integrations without real funds.

Guides › Test on a chain fork

There is no separate testnet and no faucet. The safe way to experiment is to run a fork of the live chain on your own machine with anvil (Foundry): same contracts, same pools, same balances as mainnet at the block you choose — but every transaction stays on your machine.

Run

anvil --fork-url https://rpc.btcw.tech

anvil serves RPC at http://127.0.0.1:8545, keeps chain ID 482120, and creates 10 test wallets, 10,000 BTCw each (private keys are printed to the console — local use only, never use them on mainnet). Pin the block so every run is identical:

anvil --fork-url https://rpc.btcw.tech --fork-block-number 124000

Try a swap

ME=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266          # anvil test wallet #0
RPC=http://127.0.0.1:8545
cast call 0xd953d53414a81eb6AC5a4edE73d13992181aF51E "quoteSellBtcw(uint256)(uint256)" 1000000000000000 --rpc-url $RPC
cast send 0xd953d53414a81eb6AC5a4edE73d13992181aF51E "sellBtcw(uint256)" 82000000000000000000 \
  --value 1000000000000000 --from $ME --unlocked --rpc-url $RPC
cast call 0x3b5BD179CA6Aab4DAF0f842829776843ABe6e727 "balanceOf(address)(uint256)" $ME --rpc-url $RPC

These exact commands were run on 30 Sep 2026: sold 0.001 BTCw, received ~83 USDw. Adjust minUsdOut to the quote you get.

Using the SDK and quote API with a fork

The SDK accepts an optional RPC, so quotes and prebuilt transactions are read from your fork:

import { getQuote } from "./btcw-swap.js";          // copy the file locally, see the SDK page
const q = await getQuote({ from: "native", to: "0x3b5BD179CA6Aab4DAF0f842829776843ABe6e727",
  amount: 10n ** 15n, sender: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", rpc: "http://127.0.0.1:8545" });

The btcw.tech/api/v2/swap/quote API always reads mainnet — with a fork, use the SDK as above.

Impersonate any wallet

To test with the token balances of a real wallet (on the fork only):

cast rpc anvil_impersonateAccount 0xWalletToImpersonate --rpc-url $RPC
cast send … --from 0xWalletToImpersonate --unlocked --rpc-url $RPC

Notes