<p>first install the software(bitcoin-qt) by following the steps:</p>
<pre><code>sudo apt-add-repository ppa:luke-jr/bitcoincore
sudo apt-get update    
sudo apt-get install bitcoin-qt
</code></pre>
<p>run:</p>
<pre><code>bitcoin-qt -testnet
</code></pre>
<p>since <code>testnet</code> is huge, as @Janus Troelsen suggest, there is a lighter version(<code>signet</code>):</p>
<pre><code>bitcoin-qt -signet
</code></pre>
<p><img src="https://i.sstatic.net/fgvbd.jpg" alt="bitcoin-qt testnet" /></p>
<p>click on the <code>Receive</code> button in the screenshot to get the <code>address</code></p>
<p>go to link <a href="http://tpfaucet.appspot.com/" rel="nofollow noreferrer">http://tpfaucet.appspot.com/</a> and give the <code>address</code> to get <code>testnet bitcoins</code>.</p>

CC BY-SA 4.0
2021-02-23T01:11:33.137Z
i installed it successfully. may be you need to run `sudo apt update`
suhailvs
CC BY-SA 4.0
2013-11-30T10:34:09.197Z
2021-02-22T17:59:45.320Z
2021-02-22T17:59:45.320Z
suhailvs
<p>You can use testnet, it is a separate chain: <a href="https://en.bitcoin.it/wiki/Testnet" rel="nofollow">https://en.bitcoin.it/wiki/Testnet</a></p>

CC BY-SA 3.0
2013-11-30T07:37:51.440Z
Can i create `bitcoins` without `mining`?. if not then how to mine `bitcoin` on `testnet`
suhailvs
CC BY-SA 3.0
2013-11-30T08:39:59.860Z
There are bitcoin "faucets" for testnet bitcoins. http://tpfaucet.appspot.com/
Karel Bílek
CC BY-SA 3.0
2013-11-30T08:54:09.167Z
If you want to run `bitcoin`/`bitcoind` with testnet, just use `-testnet` flag.
Karel Bílek
CC BY-SA 3.0
2013-11-30T09:16:34.213Z
@KarelBílek thank you very much for your help. but still i have `0.00` btc balance
suhailvs
CC BY-SA 3.0
2013-11-30T09:18:21.610Z
@KarelBílek in terminal i run `bitcoin-qt -testnet`
suhailvs
CC BY-SA 3.0
2013-11-30T09:42:08.070Z
@KarelBílek the link tpfaucet.appspot.com worked fine. thank you very much... :)))
suhailvs
CC BY-SA 3.0
2013-11-30T10:19:46.293Z
Is everything OK then? :)
Karel Bílek
CC BY-SA 3.0
2013-11-30T05:37:51.563Z
2013-11-30T07:09:55.127Z
2013-11-30T07:09:55.127Z
DAC
<p>Testnet is really heavy (hundreds of gigabytes), there is a lighter alternative to that now: <code>signet</code>. There is also a local-only network called <code>regtest</code>, which I put in its own section. Finally, I'll explain <code>txindex</code>, which is a useful option to have your own mini block explorer.</p>
<h1>Signet</h1>
<p>To use it, first start bitcoind with the option:</p>
<pre><code>bitcoind -signet
</code></pre>
<p>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:</p>
<pre><code>% bitcoin-cli -signet getblockchaininfo
{
  &quot;chain&quot;: &quot;signet&quot;,
  &quot;blocks&quot;: 26029
</code></pre>
<p>You can use <code>bitcoin-cli -signet getnewaddress</code> to get a new address, which you can paste into the faucet: <a href="https://signet.bc-2.jp/" rel="noreferrer">https://signet.bc-2.jp/</a> (if it complains that you have no wallet, see next section). Note how <code>signet</code> addresses also start with <code>tb</code> (which is called the &quot;human readable prefix&quot;, hrp), just like testnet addresses.</p>
<pre><code>% bitcoin-cli -signet listunspent
[
  {
    &quot;txid&quot;: &quot;9484eff65e5c33f601a8d6446859ffbc6ba59ffd53dca564d66a7c09e040c26a&quot;,
    &quot;address&quot;: &quot;tb1q7x3nnyskqmgrj9hp95fgfg75fz50x4khay3s0t&quot;,
    &quot;amount&quot;: 10.00000000,
    &quot;confirmations&quot;: 3,
</code></pre>
<p>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.</p>
<h1>Regtest</h1>
<p>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.</p>
<pre><code>% bitcoind -regtest
</code></pre>
<p>Let it run in the a separate terminal window.</p>
<p>Now you should have an empty chain:</p>
<pre><code>% bitcoin-cli -regtest getblockchaininfo
{
  &quot;chain&quot;: &quot;regtest&quot;,
  &quot;blocks&quot;: 0,
</code></pre>
<p>Now, lets see if you have a wallet:</p>
<pre><code>% bitcoin-cli -regtest getwalletinfo          
error code: -18
error message:
No wallet is loaded.
</code></pre>
<p>If you get an error like this, create a wallet:</p>
<pre><code>% bitcoin-cli -regtest createwallet testwallet
{
  &quot;name&quot;: &quot;testwallet&quot;,
  &quot;warning&quot;: &quot;&quot;
}
</code></pre>
<p>Now, you can create a new address:</p>
<pre><code>% bitcoin-cli -regtest getnewaddress          
bcrt1q0qx0d7prvrd64s3e3trq39fet7jwdecstw5tzu
</code></pre>
<p>Note how the HRP mentioned above is now &quot;bcrt&quot;, &quot;bitcoin regtest&quot;.</p>
<h2>Mining some coins</h2>
<p>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.</p>
<p>You can mine directly to the wallet (so-called <em>coinbase outputs</em>, 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):</p>
<pre><code>% bitcoin-cli -regtest generatetoaddress 10 $(bitcoin-cli -regtest getnewaddress)
[
  &quot;2e25176b5122a3d16eca11355b2807ebf99e8ef3cf01e32634417baf47cb9a4b&quot;,
  &quot;3e8136a62d513925a075700e92789d70da67d5b3dd986e936d65b12a3ba53c72&quot;,
  &quot;55ca10e3932a9087259a3826148aa660e09b69b63fe84d6a81bc4e57de052060&quot;,
  &quot;4864e894662693ae7e32cb0d2a8bc3ad94c4f5e67e109873555bc5f7b5c166bc&quot;,
  &quot;0de8a4bfb5fa5a38fba39dcf9fe360e3382e6fa56c226553c30736525bea659e&quot;,
  &quot;69e3a04724793b90de126358a99f297b821cac83b9be12f3d569effd73729199&quot;,
  &quot;3eb2a83540ce04ef75f5258359ee1695fa0b2e6cbc04a078f85e3182cd500004&quot;,
  &quot;35e39307638bca2db359ee8fa6930fbbf20e5d465882c50e05c05e2510ca2e28&quot;,
  &quot;12f2b855729929aa091a7cffccb66886a6c406c7855f8851c25ab162b17455f1&quot;,
  &quot;2414f3ddfa767aa1916f296066d35ae58c828b49e84542c57509e7161201b746&quot;
]
</code></pre>
<p>We mined some bitcoin, but you have to remember that there is &quot;coin maturity&quot;, which means that coins can not be used immediately after mining, not even on regtest.</p>
<p>So after mining these 10 blocks, you'll see that the wallet still reports no unspent outputs:</p>
<pre><code>% bitcoin-cli -regtest listunspent
[
]
</code></pre>
<p>To mature the coins, mine a hundred blocks more (I'll omit the output, it's just the command above with <code>100</code> instead of <code>10</code>), and you'll see the coins mined in the first command:</p>
<pre><code>% bitcoin-cli -regtest listunspent
  {
    &quot;txid&quot;: &quot;6fe92df06b95a20db44f989471483802a9aebc56e93057dca9fe0546445d35ff&quot;,
    &quot;vout&quot;: 0,
    &quot;address&quot;: &quot;bcrt1qlu9a5687f3m4ct3r5ndlwy8juppgghysy2s67f&quot;,
    &quot;label&quot;: &quot;&quot;,
    &quot;scriptPubKey&quot;: &quot;0014ff0bda68fe4c775c2e23a4dbf710f2e042845c90&quot;,
    &quot;amount&quot;: 50.00000000,
    &quot;confirmations&quot;: 110,
    &quot;spendable&quot;: true,
    &quot;solvable&quot;: true,
    &quot;desc&quot;: &quot;wpkh([a45ff478/0'/0'/2']02ebc0275e56ecca4a80d6a6ff7d7ab884c972cff9db9a91b9bb3681741624d41a)#rgeusc6u&quot;,
   
</code></pre>
<p>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.</p>
<h2>Processing bitcoin output with <code>jq</code></h2>
<p>Note how you can use standard JSON tools to extract information from the <code>bitcoin-cli</code> output.</p>
<p>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:</p>
<pre><code>% bitcoin-cli -regtest listunspent | jq length
10
</code></pre>
<h2>Starting over, nuke the chain</h2>
<p>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 <code>bitcoind</code> 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 <strong>shouldn't even have real (mainnet) coins in the filesystem that you run your tests from</strong>).</p>
<pre><code>% rm -rf ~/.bitcoin/regtest/
</code></pre>
<p>This isn't a true factory reset, since if you have any configuration in <code>~/.bitcoin/bitcoin.conf</code>, it would still be loaded. So if something is still working unexpectedly, check your config.</p>
<p>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 <code>blocks</code>, e.g. <code>chainstate</code>, <code>wallets</code> and <code>indexes</code>.</p>
<h1>Txindex, your own block explorer</h1>
<p>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 <code>txindex=1</code> in <code>~/.bitcoin/bitcoin.conf</code>, possibly in a <code>regtest</code> or <code>signet</code> section, though I just put it at the top-level since my mainnet coins are elsewhere, and it is useful for all testing.</p>
<p>Now, with txindex enabled, you can retrieve information on, lets say, the first transaction of block 1 (right after genesis):</p>
<pre><code>bitcoin-cli -signet decoderawtransaction $(
  bitcoin-cli -signet getrawtransaction $(
    bitcoin-cli -signet getblock $(
      bitcoin-cli -signet getblockhash 1
    ) | jq -r '.tx[0]'
  )
)
</code></pre>
<p>You get, for example, the output script these coins were locked with:</p>
<pre><code>  ...
  &quot;vout&quot;: [
    {
      &quot;value&quot;: 50.00000000,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;0 9243f727dd5343293eb83174324019ec16c2630f&quot;,
</code></pre>
<p>The &quot;getrawtransaction&quot; step requires txindex.</p>
<p>This is similar to information that you'll see in a block explorer. In this example, I used signet (which has a <a href="https://explorer.bc-2.jp/" rel="noreferrer">public block explorer</a>), but for regtest you obviously won't have a block explorer available, so the txindex could come in handy.</p>

CC BY-SA 4.0
2021-02-22T19:29:33.530Z
Thank you for rising to my challenge and going above and beyond!
Murch
CC BY-SA 4.0
2021-02-22T03:37:40.927Z
2021-02-22T04:44:51.113Z
2021-02-22T04:44:51.113Z
Janus Troelsen
<p>Is there a sandbox in Bitcoin for testing, so that I can create sample bitcoins without mining and do transactions for testing purposes?</p>

<testnet><testing><signet>
Is there a sandbox in bitcoin for testing?
suhailvs
# Is there a sandbox in bitcoin for testing?

(Asked by: username_0 on 2013-11-30)

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

**Tags:** testnet, testing, signet


---

## 3 answers

### Answer by username_3 on 2021-02-22. Score: 13 | Accepted answer

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.

# Signet

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.

# Regtest

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          
bcrt1q0qx0d7prvrd64s3e3trq39fet7jwdecstw5tzu

```

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)
[
  "2e25176b5122a3d16eca11355b2807ebf99e8ef3cf01e32634417baf47cb9a4b",
  "3e8136a62d513925a075700e92789d70da67d5b3dd986e936d65b12a3ba53c72",
  "55ca10e3932a9087259a3826148aa660e09b69b63fe84d6a81bc4e57de052060",
  "4864e894662693ae7e32cb0d2a8bc3ad94c4f5e67e109873555bc5f7b5c166bc",
  "0de8a4bfb5fa5a38fba39dcf9fe360e3382e6fa56c226553c30736525bea659e",
  "69e3a04724793b90de126358a99f297b821cac83b9be12f3d569effd73729199",
  "3eb2a83540ce04ef75f5258359ee1695fa0b2e6cbc04a078f85e3182cd500004",
  "35e39307638bca2db359ee8fa6930fbbf20e5d465882c50e05c05e2510ca2e28",
  "12f2b855729929aa091a7cffccb66886a6c406c7855f8851c25ab162b17455f1",
  "2414f3ddfa767aa1916f296066d35ae58c828b49e84542c57509e7161201b746"
]

```

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
10

```

## 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](https://explorer.bc-2.jp/)), but for regtest you obviously won't have a block explorer available, so the txindex could come in handy.

> **Comments:**
> **username_4**: Thank you for rising to my challenge and going above and beyond!  

---

### Answer by username_0 on 2013-11-30. Score: 3

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

```

run:

```
bitcoin-qt -testnet

```

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

```
bitcoin-qt -signet

```

![bitcoin-qt testnet](https://i.sstatic.net/fgvbd.jpg)

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`.

> **Comments:**
> **username_0**: i installed it successfully. may be you need to run `sudo apt update`  

---

### Answer by username_1 on 2013-11-30. Score: 2

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

> **Comments:**
> **username_0**: Can i create `bitcoins` without `mining`?. if not then how to mine `bitcoin` on `testnet`  
> **username_2**: There are bitcoin "faucets" for testnet bitcoins. http://tpfaucet.appspot.com/  
> **username_2**: If you want to run `bitcoin`/`bitcoind` with testnet, just use `-testnet` flag.  
> **username_0**: @username_2 thank you very much for your help. but still i have `0.00` btc balance  
> **username_0**: @username_2 in terminal i run `bitcoin-qt -testnet`  
> **username_0**: @username_2 the link tpfaucet.appspot.com worked fine. thank you very much... :)))  
> **username_2**: Is everything OK then? :)  

---

