Is there a sandbox in Bitcoin for testing, so that I can create sample bitcoins without mining and do transactions for testing purposes?


Testnet is really heavy (hundreds of gigabytes), there is a lighter alternative to that now: signet. There is also a local-only network called regtest, which I put in its own section. Finally, I'll explain txindex, which is a useful option to have your own mini block explorer.


To use it, first start bitcoind with the option:

bitcoind -signet

It will need to sync, but it will be a lot faster than testnet since the chain started recently and as of writing only has about 27000 blocks:

% bitcoin-cli -signet getblockchaininfo
  "chain": "signet",
  "blocks": 26029

You can use bitcoin-cli -signet getnewaddress to get a new address, which you can paste into the faucet: https://signet.bc-2.jp/ (if it complains that you have no wallet, see next section). Note how signet addresses also start with tb (which is called the "human readable prefix", hrp), just like testnet addresses.

% bitcoin-cli -signet listunspent
    "txid": "9484eff65e5c33f601a8d6446859ffbc6ba59ffd53dca564d66a7c09e040c26a",
    "address": "tb1q7x3nnyskqmgrj9hp95fgfg75fz50x4khay3s0t",
    "amount": 10.00000000,
    "confirmations": 3,

If you don't see anything right away, wait a bit. Once the transaction arrives, you'll see the confirmation count rising at a regular interval. Signet has much more regular blocks than testnet.


The regtest is not really a network, since it isn't meant to be used publicly. The chain starts with the genesis, and proof-of-work is effectively disabled, so you can just mine your own blocks. This is useful if you need to test reorgs and stuff like that, which you won't be able to do with signet.

% bitcoind -regtest

Let it run in the a separate terminal window.

Now you should have an empty chain:

% bitcoin-cli -regtest getblockchaininfo
  "chain": "regtest",
  "blocks": 0,

Now, lets see if you have a wallet:

% bitcoin-cli -regtest getwalletinfo          
error code: -18
error message:
No wallet is loaded.

If you get an error like this, create a wallet:

% bitcoin-cli -regtest createwallet testwallet
  "name": "testwallet",
  "warning": ""

Now, you can create a new address:

% bitcoin-cli -regtest getnewaddress          

Note how the HRP mentioned above is now "bcrt", "bitcoin regtest".

Mining some coins

That's right, CPU mining is alive and well ;) In fact, regtest only has blocks when you generate some, yourself. That's nice for testing, you have time to figure out.

You can mine directly to the wallet (so-called coinbase outputs, you may have heard of a company named after these). Here I am using the shell to insert an address generated using the command from above (should work in PowerShell on Windows too):

% bitcoin-cli -regtest generatetoaddress 10 $(bitcoin-cli -regtest getnewaddress)

We mined some bitcoin, but you have to remember that there is "coin maturity", which means that coins can not be used immediately after mining, not even on regtest.

So after mining these 10 blocks, you'll see that the wallet still reports no unspent outputs:

% bitcoin-cli -regtest listunspent

To mature the coins, mine a hundred blocks more (I'll omit the output, it's just the command above with 100 instead of 10), and you'll see the coins mined in the first command:

% bitcoin-cli -regtest listunspent
    "txid": "6fe92df06b95a20db44f989471483802a9aebc56e93057dca9fe0546445d35ff",
    "vout": 0,
    "address": "bcrt1qlu9a5687f3m4ct3r5ndlwy8juppgghysy2s67f",
    "label": "",
    "scriptPubKey": "0014ff0bda68fe4c775c2e23a4dbf710f2e042845c90",
    "amount": 50.00000000,
    "confirmations": 110,
    "spendable": true,
    "solvable": true,
    "desc": "wpkh([a45ff478/0'/0'/2']02ebc0275e56ecca4a80d6a6ff7d7ab884c972cff9db9a91b9bb3681741624d41a)#rgeusc6u",

There will be a ten tx's like this, because the ten blocks that we initially mined have all matured. They have confirmation counts from 101 to 110.

Processing bitcoin output with jq

Note how you can use standard JSON tools to extract information from the bitcoin-cli output.

For example, we can verify the number of unspent wallet outputs. In the example from the previous section, we mined 110 blocks, that each have one coinbase output for the Core wallet. But only the first 10 have matured:

% bitcoin-cli -regtest listunspent | jq length

Starting over, nuke the chain

You'll possibly want to reset your testing environment before and/or after running a test. With regtest, you can remove the whole blockchain. So shut down the bitcoind process that we started above. You can simply wipe the regtest directory, but be very careful that you don't wipe the wrong one (actually, you shouldn't even have real (mainnet) coins in the filesystem that you run your tests from).

% rm -rf ~/.bitcoin/regtest/

This isn't a true factory reset, since if you have any configuration in ~/.bitcoin/bitcoin.conf, it would still be loaded. So if something is still working unexpectedly, check your config.

Deleting a signet blockchain makes less sense, since you'd just download the exact same chain after relaunching (unless something is horribly broken). So to ensure a clean signet testing environment, maybe just wipe everything except blocks, e.g. chainstate, wallets and indexes.

Txindex, your own block explorer

Bitcoin Core has a neat feature that lets you look up information on an arbitrary transaction. But you enable must it first. To do that, write txindex=1 in ~/.bitcoin/bitcoin.conf, possibly in a regtest or signet section, though I just put it at the top-level since my mainnet coins are elsewhere, and it is useful for all testing.

Now, with txindex enabled, you can retrieve information on, lets say, the first transaction of block 1 (right after genesis):

bitcoin-cli -signet decoderawtransaction $(
  bitcoin-cli -signet getrawtransaction $(
    bitcoin-cli -signet getblock $(
      bitcoin-cli -signet getblockhash 1
    ) | jq -r '.tx[0]'

You get, for example, the output script these coins were locked with:

  "vout": [
      "value": 50.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 9243f727dd5343293eb83174324019ec16c2630f",

The "getrawtransaction" step requires txindex.

This is similar to information that you'll see in a block explorer. In this example, I used signet (which has a public block explorer), but for regtest you obviously won't have a block explorer available, so the txindex could come in handy.

  • 1
    Thank you for rising to my challenge and going above and beyond! – Murch Feb 22 at 19:29

You can use testnet, it is a separate chain: https://en.bitcoin.it/wiki/Testnet

  • Can i create bitcoins without mining?. if not then how to mine bitcoin on testnet – suhailvs Nov 30 '13 at 7:37
  • There are bitcoin "faucets" for testnet bitcoins. tpfaucet.appspot.com – Karel Bílek Nov 30 '13 at 8:39
  • If you want to run bitcoin/bitcoind with testnet, just use -testnet flag. – Karel Bílek Nov 30 '13 at 8:54
  • @KarelBílek thank you very much for your help. but still i have 0.00 btc balance – suhailvs Nov 30 '13 at 9:16
  • @KarelBílek in terminal i run bitcoin-qt -testnet – suhailvs Nov 30 '13 at 9:18

first install the software(bitcoin-qt) by following the steps:

sudo apt-add-repository ppa:luke-jr/bitcoincore
sudo apt-get update    
sudo apt-get install bitcoin-qt


bitcoin-qt -testnet

since testnet is huge, as @Janus Troelsen suggest, there is a lighter version(signet):

bitcoin-qt -signet

bitcoin-qt testnet

click on the Receive button in the screenshot to get the address

go to link http://tpfaucet.appspot.com/ and give the address to get testnet bitcoins.

  • 1
    i installed it successfully. may be you need to run sudo apt update – suhailvs Feb 23 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.