Guides / Build a testnet app

Build a testnet app

This capstone ties the developer guides into one loop: reach a chain, read from it, build and broadcast a transaction, and watch it confirm, all on testnet where every mistake is free.

Runnable code

Every recipe here has copy-paste-runnable Python and JavaScript in the companion repo, testnet-examples.

On this page

Why build on testnet first

Testnet runs the same protocol as mainnet with coins that are worth nothing. That makes it the right place to write and debug an integration: you can fund an address for free from the faucet, send real transactions, and get everything wrong without losing a cent.

Two ways to reach a chain

An app needs a way to read the chain and push transactions to it. You have two options, and many apps use both:

  • Run your own node and talk to it over RPC. Full control and no third party, but you run the infrastructure.
  • Use an explorer API over HTTP. No infrastructure to run, and it works straight from a browser.

Path A: your own node

Set one up with run a Litecoin testnet node (the same pattern works for Bitcoin), then drive it over RPC:

litecoin-cli -testnet getblockchaininfo      # is it synced?
litecoin-cli -testnet getnewaddress          # an address to fund
litecoin-cli -testnet listunspent            # your spendable UTXOs
litecoin-cli -testnet gettransaction <txid>   # a wallet tx + its confirmations

The RPC interface can move funds, so keep it private. Read use node RPC safely before you expose anything.

Path B: an explorer API

If you would rather not run a node, TestnetScan exposes a public, CORS-enabled HTTP API that is compatible with the mempool.space and Esplora conventions. The base is https://testnetscan.com/{net}/api/, where {net} is btc-testnet4 or ltc-testnet. A few examples you can run right now:

# current block height (plain number)
curl https://testnetscan.com/btc-testnet4/api/blocks/tip/height

# suggested fee rates (sat/vB, by target in blocks)
curl https://testnetscan.com/btc-testnet4/api/fee-estimates

# mempool summary
curl https://testnetscan.com/btc-testnet4/api/mempool

Address history, UTXOs, and transaction lookups follow the same Esplora-style paths (for example /api/address/<addr> and /api/tx/<txid>). Because the API answers with Access-Control-Allow-Origin: *, you can call it directly from front-end JavaScript. See the full reference in TestnetScan's API docs.

Build and broadcast

Building a transaction means selecting UTXOs, adding outputs, setting a fee, and signing. Do it with a library in your language (for example a Bitcoin or Litecoin transaction-builder package) or let a wallet handle it. Then push the signed hex, either through your node or an explorer:

# via your node
litecoin-cli -testnet sendrawtransaction <signed-hex>

# or via the explorer (POST the raw hex)
curl -X POST --data <signed-hex> https://testnetscan.com/ltc-testnet/api/tx

The full walkthrough, including how to inspect a transaction before you send it and what the common rejection errors mean, is in broadcast a raw transaction.

Watch it confirm

After broadcasting, poll until the transaction has enough confirmations for your use case. Ask the explorer for the transaction's status, or your node with gettransaction <txid>, which reports a live confirmation count for your wallet's transactions. If it never appears, see debugging a stuck transaction.

The whole loop

A minimal end-to-end run

Get an address

From your wallet or getnewaddress.

Fund it

Claim coins from the faucet, then confirm they arrived via the explorer API or listunspent.

Build and sign

Select UTXOs, add your output plus a change output, set a fee, and sign.

Broadcast

Push the signed hex with sendrawtransaction or the explorer's broadcast endpoint.

Poll for confirmation

Check the transaction's confirmation count until it clears your threshold.

Before you go to mainnet

The code you write on testnet is the code you will run on mainnet, so build the safe habits now:

  • Never reuse a testnet seed or key on mainnet. Generate fresh keys for real funds.
  • Keep node RPC private. An exposed wallet RPC has drained real money.
  • Wait for enough confirmations before treating a payment as final, and handle reorgs.
  • Estimate fees from live data, and have a plan for stuck transactions (RBF or CPFP).

Testnet coins are fake money

  • They have no market value, so never buy or sell them.
  • Never use a real seed phrase or import a real wallet on testnet.
  • Never send mainnet BTC, LTC, or XMR to a testnet address.