<p><code>generatetoaddress</code> generates a block using transactions from the mempool. It uses the given address for the coinbase output.</p>
<p><code>generateblock</code> generates a block with the given transactions in the given order. It does not automatically select transactions from the mempool like <code>generatetoaddress</code> does.</p>
<p>Both RPCs are only relevant on regtest and are used for testing. <code>generatetoaddress</code> is generally used when any unconfirmed transactions can be included in the block. <code>generateblock</code> is used when only some specific transactions should be included. <code>generatetoaddress</code> is also used to generate coins via coinbase transactions.</p>

CC BY-SA 4.0
2021-11-04T16:01:20.460Z
2021-11-04T16:01:20.460Z
Ava Chow
<p>Both commands generate blocks, and one specifies an address, what is the usage for each? Thanks!</p>

<bitcoind><json-rpc><bitcoin-cli>
What's the difference between generateblock and generatetoaddress
LesserFlow
# What's the difference between generateblock and generatetoaddress

(Asked by: username_0 on 2021-11-04)

Both commands generate blocks, and one specifies an address, what is the usage for each? Thanks!

**Tags:** bitcoind, json-rpc, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2021-11-04. Score: 1

`generatetoaddress` generates a block using transactions from the mempool. It uses the given address for the coinbase output.

`generateblock` generates a block with the given transactions in the given order. It does not automatically select transactions from the mempool like `generatetoaddress` does.

Both RPCs are only relevant on regtest and are used for testing. `generatetoaddress` is generally used when any unconfirmed transactions can be included in the block. `generateblock` is used when only some specific transactions should be included. `generatetoaddress` is also used to generate coins via coinbase transactions.


---

