Skip to content

Latest commit

 

History

History

README.md

Python examples

Runnable testnet recipes in Python (3.8+). See the top-level README for the full recipe list and how each maps to a TestnetHub guide.

Setup

pip install -r requirements.txt   # just `requests`

Run

python 00_new_key.py                     # a fresh receive address     (needs a node)
python 01_tip_height.py                  # current block height        (no node)
python 02_address.py [address]           # balance + UTXOs             (no node)
python 03_fees.py                        # fee estimates               (no node)
python 04_mempool.py                     # mempool summary             (no node)
python 05_broadcast.py <signed-hex>      # broadcast a signed tx       (no node)
python 06_watch.py <txid> [confs]        # poll until confirmed        (no node)
python 07_node_rpc.py                    # needs RPC_USER/RPC_PASS + a node
python 08_build_and_send.py <addr> <amt> # needs a funded node wallet
python 09_monero_info.py                 # needs monerod --stagenet
python 10_decode_tx.py <txid>            # decode + draw a transaction  (no node)
python 11_block.py [height]              # fetch + draw a block         (no node)
python 12_monero_block.py [height]       # Monero block/tx, amounts hidden (needs monerod)
python 13_monero_wallet.py               # Monero wallet address + balance (needs monero-wallet-rpc)
python 14_op_return.py "your message"    # write a message on-chain    (needs a node)
python 15_address_types.py               # legacy/SegWit/Taproot types (needs a node)

Config

config.py reads everything from environment variables; the defaults are shown below:

Var Used by Default
TESTNET_API 01-06, 10, 11 https://testnetscan.com
TESTNET_NET 01-06, 10, 11 btc-testnet4 (or ltc-testnet)
RPC_URL / RPC_USER / RPC_PASS 00, 07, 08, 14, 15 http://127.0.0.1:19332 (Litecoin testnet; Bitcoin testnet4 is :48332)
MONEROD 09, 12 http://127.0.0.1:38081
MONERO_WALLET_RPC 13 http://127.0.0.1:38083

Recipes 01-06 hit TestnetScan's public API and need nothing installed beyond requests. Get coins to play with from CypherFaucet.