<p>Yes.</p>
<p>A block is valid even with no transactions other than the coinbase transaction. There have been many such blocks. This is especially true for early blocks of the blockchain.</p>
<hr />
<ul>
<li><a href="https://www.theblockcrypto.com/linked/1964/close-to-19-of-mined-bitcoin-blocks-were-empty" rel="nofollow noreferrer">Close to 19% of mined Bitcoin blocks were empty</a> - Steven Zheng.
October 17, 2018</li>
<li><a href="https://www.theblockcrypto.com/post/67928/bitcoin-miners-are-mining-fewer-empty-blocks-in-2020-and-it-may-not-all-because-of-chance" rel="nofollow noreferrer">A total of 71 empty blocks were mined in the first five months of 2020, accounting for 0.3% of the total blocks produced</a></li>
</ul>
<p><a href="https://i.sstatic.net/XqAL6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XqAL6.png" alt="Average number of BTC transactions per block" /></a> (<a href="https://cointelegraph.com/news/the-current-state-of-the-bitcoin-network-and-its-biggest-block" rel="nofollow noreferrer">source: Cointelegraph</a>)</p>

CC BY-SA 4.0
2021-09-26T14:56:55.490Z
2021-09-26T15:02:23.023Z
2021-09-26T15:02:23.023Z
RedGrittyBrick
<p>Based on what <a href="https://en.bitcoin.it/wiki/Getblocktemplate" rel="nofollow noreferrer">I read</a>, there is this script to build the Merkle root</p>
<pre><code>import hashlib     
def dblsha(data):      
    return hashlib.sha256(hashlib.sha256(data).digest()).digest()     
 
txnlist = [coinbase] + [binascii.a2b_hex(a['data']) for a in template['transactions']]     
merklehashes = [dblsha(t) for t in txnlist]     
while len(merklehashes) &gt; 1:     
     if len(merklehashes) % 2:     
        merklehashes.append(merklehashes[-1])      
    merklehashes = [dblsha(merklehashes[i] + merklehashes[i + 1]) for i in range(0, len(merklehashes), 2)]      
merkleroot = merklehashes[0]        
   
</code></pre>
<p>I wanted to mine an empty block (a block with only a coinbase transaction in it) , can I modify the script so that <code>txnlist</code> only includes coinbase and ignore the other transactions? or it is  considered a hard fork?</p>
<pre><code>txnlist = [coinbase]       
 
</code></pre>
<p>Or this isn't the correct way to mine empty block?</p>
<p>I currently only have a shallow understanding of Bitcoin, that's why I ask.</p>

CC BY-SA 4.0
2024-12-11T18:02:23.017Z
similar: [What happens if there are no transactions in a block?](https://bitcoin.stackexchange.com/questions/2021/what-happens-if-there-are-no-transactions-in-a-block). If you believe it’s different, please [edit] the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.
Pat Myron
<mining-software><empty-blocks>
Can I mine a block with no transactions other than the coinbase?
user6668201
# Can I mine a block with no transactions other than the coinbase?

(Asked by: username_0 on 2021-09-26)

Based on what [I read](https://en.bitcoin.it/wiki/Getblocktemplate), there is this script to build the Merkle root

```
import hashlib     
def dblsha(data):      
    return hashlib.sha256(hashlib.sha256(data).digest()).digest()     
 
txnlist = [coinbase] + [binascii.a2b_hex(a['data']) for a in template['transactions']]     
merklehashes = [dblsha(t) for t in txnlist]     
while len(merklehashes) > 1:     
     if len(merklehashes) % 2:     
        merklehashes.append(merklehashes[-1])      
    merklehashes = [dblsha(merklehashes[i] + merklehashes[i + 1]) for i in range(0, len(merklehashes), 2)]      
merkleroot = merklehashes[0]        
   

```

I wanted to mine an empty block (a block with only a coinbase transaction in it) , can I modify the script so that `txnlist` only includes coinbase and ignore the other transactions? or it is considered a hard fork?

```
txnlist = [coinbase]       
 

```

Or this isn't the correct way to mine empty block?

I currently only have a shallow understanding of Bitcoin, that's why I ask.

**Tags:** mining-software, empty-blocks

> **Comments:**
> **username_1**: similar: [What happens if there are no transactions in a block?](https://bitcoin.stackexchange.com/questions/2021/what-happens-if-there-are-no-transactions-in-a-block). If you believe it’s different, please [edit] the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.  

---

## 1 answers

### Answer by username_2 on 2021-09-26. Score: 2 | Accepted answer

Yes.

A block is valid even with no transactions other than the coinbase transaction. There have been many such blocks. This is especially true for early blocks of the blockchain.

---

* [Close to 19% of mined Bitcoin blocks were empty](https://www.theblockcrypto.com/linked/1964/close-to-19-of-mined-bitcoin-blocks-were-empty) - Steven Zheng.
  October 17, 2018
* [A total of 71 empty blocks were mined in the first five months of 2020, accounting for 0.3% of the total blocks produced](https://www.theblockcrypto.com/post/67928/bitcoin-miners-are-mining-fewer-empty-blocks-in-2020-and-it-may-not-all-because-of-chance)

[![Average number of BTC transactions per block](https://i.sstatic.net/XqAL6.png)](https://i.sstatic.net/XqAL6.png) ([source: Cointelegraph](https://cointelegraph.com/news/the-current-state-of-the-bitcoin-network-and-its-biggest-block))


---

