<ol>
<li><p>Put your client into regtest mode. This allows you to mine an arbitrary amount of blocks very quickly. Add this to your bitcoin.conf</p>

<pre><code>regtest=1
daemon=1
</code></pre></li>
<li><p>Generate the blocks. Run </p>

<pre><code>bitcoin-cli setgenerate true &lt;number of blocks&gt;
</code></pre>

<p>where X is the number of block you want. You'll want at least 101 blocks.</p></li>
<li><p>See the mined blocks. Run</p>

<pre><code>bitcoin-cli getblockhash &lt;index&gt;
</code></pre>

<p>to get the hash of block number <code>&lt;index&gt;</code>. Then take that hash and run</p>

<pre><code>bitcoin-cli getblock &lt;hash&gt;
</code></pre></li>
<li><p>Repeat Step 3 for each block you want.</p></li>
<li><p>Send the Bitcoins to a new address. Run</p>

<pre><code>bitcoin-cli getbalance
</code></pre>

<p>to find out your balance. Run</p>

<pre><code>bitcoin-cli sendtoaddress &lt;address&gt; &lt;amount&gt;
</code></pre></li>
</ol>

<p>If you don't need to see the contents of the block, you can skip steps 3 and 4.</p>

CC BY-SA 3.0
2015-04-01T06:53:15.943Z
2015-04-01T06:53:15.943Z
Nick ODell
<p><code>setgenerate</code> has been removed. and now you can use <code>generatetoaddress</code> to mine.</p>

<pre><code># generatetoaddress
generatetoaddress 1 2NDyXhf4i44Vqpy9FvPHXkw8ccA2WtMkTe3
</code></pre>

CC BY-SA 4.0
2019-05-08T06:48:07.043Z
2019-05-08T06:48:07.043Z
Vishwas Bhushan
<p>Assuming that there is a magical <code>mineblocks</code> RPC command that can mine X blocks on demand, what is the complete set of command line commands to start a client, mine my coins to a specific address, see the mined blocks, get the reward and send them to an address XXX?</p>

<json-rpc>
From mining to sending via RPC
rmac
# From mining to sending via RPC

(Asked by: username_0 on 2015-04-01)

Assuming that there is a magical `mineblocks` RPC command that can mine X blocks on demand, what is the complete set of command line commands to start a client, mine my coins to a specific address, see the mined blocks, get the reward and send them to an address XXX?

**Tags:** json-rpc


---

## 2 answers

### Answer by username_1 on 2015-04-01. Score: 1

Put your client into regtest mode. This allows you to mine an arbitrary amount of blocks very quickly. Add this to your bitcoin.conf
regtest=1
daemon=1

Generate the blocks. Run 
bitcoin-cli setgenerate true 

where X is the number of block you want. You'll want at least 101 blocks.
See the mined blocks. Run
bitcoin-cli getblockhash 

to get the hash of block number . Then take that hash and run
bitcoin-cli getblock 

Repeat Step 3 for each block you want.
Send the Bitcoins to a new address. Run
bitcoin-cli getbalance

to find out your balance. Run
bitcoin-cli sendtoaddress  


If you don't need to see the contents of the block, you can skip steps 3 and 4.


---

### Answer by username_2 on 2019-05-08. Score: 0

setgenerate has been removed. and now you can use generatetoaddress to mine.
# generatetoaddress
generatetoaddress 1 2NDyXhf4i44Vqpy9FvPHXkw8ccA2WtMkTe3


---

