Suffix

Published by Simon Schoeters

Getting started: Bitcoin testnet

Are you a developer working on a Bitcoin project or are you a power user discovering the more advanced Bitcoin features? This post explains how to get started with the Bitcoin testnet so you can play without using your real, hard-earned coins.

None of the Bitcoin client applications implement all of those features, (yet) so you'll have to use the Bitcoin RPC interface from the command line.

Install

Download and install the Bitcoin Core client (previously named Bitcoin-Qt). You can, but don't have to, start the application. It will start downloading the huge, real blockchain, which you don't need for testing.

Configure

  1. Find the Bitcoin Core data directory for your system.
  2. Create this directory if it doesn't exist yet (should be there from when you ran the client before). On Mac OS X for example:

    mkdir ~/Library/Application\ Support/Bitcoin/

  3. Create a bitcoin.conf configuration file in that directory. A minimal example might look like:
    testnet=1
    server=1
    rpcuser=Ulysseys
    rpcpassword=YourPassword
    rpctimeout=30
    rpcport=8332

Run

Start the Bitcoin Core client. The application icon should be green instead of orange. The green icon indicates it's running in testnet mode. The client will start downloading the testnet blockchain and this will take a while.

While you wait for the testnet blockchain to download, you can grab some testnet coins. Find a Bitcoin testnet faucet and send yourself some coins (you can find an address in the Bitcoin Core client).

The coins will only show up in the Bitcoin Core client application when the blockchain download has caught up, so wait for it to finish.

Play

Time to try it out. Here is a simple cURL command to ask the Bitcoin daemon for some general info using a JSON RPC:

curl --user Ulysseys --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/