<p>The block size is the combination of the block header and the list of transactions. Specifically, the block header has these fields:</p>

<ul>
<li>version - 4 bytes</li>
<li>previous block header hash - 32 bytes</li>
<li>merkle root hash - 32 bytes</li>
<li>time - 4 bytes</li>
<li>nBits (encoded POW target) - 4 bytes</li>
<li>nonce - 4 bytes</li>
</ul>

<p>So the total bytes for a block header is
4 + 32 + 32 + 4 + 4 + 4 = 80 bytes</p>

<p>After the block header is the list of transactions which is</p>

<ul>
<li>transaction count - 1-9 bytes</li>
<li>transactions - varies</li>
</ul>

<p>Transactions can vary greatly in terms of the number of bytes, but the general serialization of a single transaction is:</p>

<ul>
<li>version - 4 bytes</li>
<li>tx in size - 1-9 bytes</li>
<li>tx ins - see below</li>
<li>tx out size - 1-9 bytes</li>
<li>tx outs - see below</li>
<li>locktime - 4 bytes</li>
</ul>

<p>Each tx in has these fields:</p>

<ul>
<li>previous tx out hash - 32 bytes</li>
<li>previous tx out position - 4 bytes</li>
<li>pubkey script - varies depending on script, max 10,000 bytes</li>
<li>signature script - varies</li>
<li>sequence - 4 bytes</li>
</ul>

<p>Each tx out has these fields:</p>

<ul>
<li>value - 8 bytes</li>
<li>pubkey script length - 1-9 bytes</li>
<li>pubkey script - varies</li>
</ul>

<p>The sum total of all these things in a block determine the size, which currently has to be less than 1 MB.</p>

CC BY-SA 4.0
2021-04-22T14:13:03.047Z
block size = total block size - 8 bytes. The 8 being magic number and block size fields right?
Bitcoingraffiti
CC BY-SA 3.0
2015-11-03T03:06:00.693Z
2015-11-03T03:06:00.693Z
Jimmy Song
<p>How is the blocksize currently calculated in Bitcoin Core? I'm specifically asking about how it's done for the purposes of enforcing the 1MB limit. If it's done by calculating the serialization length, what serialization format is used?</p>

CC BY-SA 3.0
2015-11-03T01:50:46.700Z
Don't know the exact answer, but these code snippets from bitcoin-core might help:

https://github.com/bitcoin/bitcoin/blob/master/src/consensus/consensus.h#L10

https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L2640

https://github.com/bitcoin/bitcoin/blob/master/src/serialize.h
Josh Cincinnati
<bitcoind><blocksize>
How is the size of a block calculated?
Nick ODell
# How is the size of a block calculated?

(Asked by: username_0 on 2015-11-02)

How is the blocksize currently calculated in Bitcoin Core? I'm specifically asking about how it's done for the purposes of enforcing the 1MB limit. If it's done by calculating the serialization length, what serialization format is used?

**Tags:** bitcoind, blocksize

> **Comments:**
> **username_1**: Don't know the exact answer, but these code snippets from bitcoin-core might help:  https://github.com/bitcoin/bitcoin/blob/master/src/consensus/consensus.h#L10  https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L2640  https://github.com/bitcoin/bitcoin/blob/master/src/serialize.h  

---

## 1 answers

### Answer by username_2 on 2015-11-03. Score: 7 | Accepted answer

The block size is the combination of the block header and the list of transactions. Specifically, the block header has these fields:

* version - 4 bytes
* previous block header hash - 32 bytes
* merkle root hash - 32 bytes
* time - 4 bytes
* nBits (encoded POW target) - 4 bytes
* nonce - 4 bytes

So the total bytes for a block header is
4 + 32 + 32 + 4 + 4 + 4 = 80 bytes

After the block header is the list of transactions which is

* transaction count - 1-9 bytes
* transactions - varies

Transactions can vary greatly in terms of the number of bytes, but the general serialization of a single transaction is:

* version - 4 bytes
* tx in size - 1-9 bytes
* tx ins - see below
* tx out size - 1-9 bytes
* tx outs - see below
* locktime - 4 bytes

Each tx in has these fields:

* previous tx out hash - 32 bytes
* previous tx out position - 4 bytes
* pubkey script - varies depending on script, max 10,000 bytes
* signature script - varies
* sequence - 4 bytes

Each tx out has these fields:

* value - 8 bytes
* pubkey script length - 1-9 bytes
* pubkey script - varies

The sum total of all these things in a block determine the size, which currently has to be less than 1 MB.

> **Comments:**
> **username_3**: block size = total block size - 8 bytes. The 8 being magic number and block size fields right?  

---

