Small, runnable code examples for the Bitcoin, Litecoin, and Monero testnets.
The companion code repo to TestnetHub. TestnetHub teaches the concepts; this repo is where you run them against real test networks. Every example is short, heavily commented, and does one thing. Nothing here touches real money.
Each recipe comes in Python (python/) and JavaScript / Node
(javascript/). The read-only ones need no node and no keys: they call
TestnetScan's public, CORS-enabled, Esplora / mempool.space
compatible API. The node recipes talk to your own bitcoind / litecoind / monerod.
| # | Recipe | Needs | TestnetHub guide |
|---|---|---|---|
| 00 | New key + address | see file | Keys & seeds |
| 01 | Current block height | API only | Read the chain |
| 02 | Address balance + UTXOs | API only | UTXOs |
| 03 | Fee estimates | API only | Fees |
| 04 | Mempool summary | API only | Fees |
| 05 | Broadcast a signed transaction | API only | Broadcast a raw tx |
| 06 | Watch a transaction confirm | API only | Confirmations |
| 07 | Talk to a node over RPC | a node | Run a node |
| 08 | Build, sign, and send a transaction | see file | Build a testnet app |
| 09 | Monero daemon info (stagenet) | monerod | Monero |
| 10 | Decode and visualize a transaction | API only | Read the chain |
| 11 | Fetch and visualize a block | API only | Read the chain |
| 12 | Monero block/tx, and what stays hidden | monerod | Monero |
| 13 | Monero wallet: address, balance, view key | monero-wallet-rpc | Monero |
| 14 | Write a message on-chain (OP_RETURN) | see file | Broadcast a raw tx |
| 15 | Address types from one key (Legacy, SegWit, Taproot) | see file | Keys & seeds |
- End to end: chain the recipes into one flow, from a fresh key to a confirmed transaction, in both languages.
- Regtest: run a private local chain where you mine blocks on demand and confirmations are instant.
Base URL: https://testnetscan.com/{net}/api/ where {net} is btc-testnet4 or
ltc-testnet. Example: curl https://testnetscan.com/btc-testnet4/api/blocks/tip/height.
It follows the Esplora /
mempool.space conventions.
Python (3.8+):
cd python
pip install -r requirements.txt # just `requests`
python 01_tip_height.pyJavaScript (Node 18+, uses built-in fetch):
cd javascript
node 01_tip_height.js
# recipes 00, 08, 14, and 15 need libraries: npm installGet testnet coins to play with from CypherFaucet. Need a wallet or a node first? See the TestnetHub guides.
Testnet coins are worth nothing, which is the whole point: experiment freely. Even so, never put a real seed phrase, private key, or mainnet address into these scripts. Generate fresh testnet keys. See why testnet coins have no value.
MIT so you can lift any snippet straight into your own project. Part of the Tech1k testnet ecosystem.