Powered by Gemini
sg

Your trusted source for all things crypto.

Powered by Gemini
cryptopedia-trademark-logo
search

How a Block in the Bitcoin Blockchain Works

Here, we explore the key components of the individual blockchain blocks that comprise the Bitcoin network.

By Cryptopedia Staff

Updated March 24, 20224 min read

How a Block in the Bitcoin Blockchain Works -100

Summary

A blockchain network’s transactions are composed of sequential groups of data that are packaged together into “blocks” strung together linearly. Each block also contains a set of transaction data that is processed once the block is finalized. The individual blocks that make up the larger blockchain contain crucial information for the functioning of the network. Each new block contains cryptographically verifiable data regarding transactions, as well as a numerical challenge that must be completed in order for the current block to be approved and added to the blockchain. Here, we will explore the anatomical structure of a block in the Bitcoin blockchain and the respective roles of its individual components.

Introduction to Bitcoin Blocks

The Bitcoin network maintains a distributed public ledger that records the ownership and transactions of all bitcoin (BTC), the native digital asset of the Bitcoin network. As transactions take place over the network, transaction data is grouped together into “blocks” and added chronologically to the network’s ongoing linear chain of data blocks — hence the term “blockchain.”

The blocks that make up the blockchain’s ongoing sequence of transactions are intended to be structurally identical. Each block contains a block header as well as transaction data — two crucial sets of information integral to the network’s proper function and ability to transfer value. Each block must also contain certain specific information in order to be recognized by the network and subsequently become properly validated and appended to the blockchain.

The overall structure of a Bitcoin block always includes the following elements:

  • Magic number: This 4-byte field always contains the value 0xD9B4BEF9, which indicates that the file format adheres to a data structure that corresponds to the Bitcoin network.

  • Blocksize: This 4-byte field sets a cap on the amount of data that can be contained in a block. The Bitcoin block size is limited to one megabyte (MB).

  • Block header: This 80-byte field consists of six individual components, discussed in more detail below.

  • Transaction counter: This field can range in size from one to nine bytes and is a positive integer that represents the number of transactions contained in the Bitcoin block.

  • Transactions: This variable size field contains the list of all transactions contained in the block and is typically filled with enough transactions to fill the 1MB Bitcoin block size limit.

The block header and the transaction data represent the two main categories of data in any given block — though these two sections are further broken down into individual components that we will discuss in more detail.

Bitcoin Block Headers and Mining

The Bitcoin network fundamentally relies on a decentralized network of nodes that maintain the distributed public ledger of all bitcoin transactions. Network nodes may also participate in a process called mining, which secures the network and ensures the authenticity of new blocks and the transactions they contain. Miners are responsible for writing new blocks to the blockchain, so their role in verifying the integrity of information contained within a proposed block is paramount. The Bitcoin block time is ten minutes (on average), so around six new blocks are written to Bitcoin every hour.

The block header contains 80 bytes of cryptographically verifiable information:

  • Version: This 4-byte field indicates the version number of the Bitcoin protocol being used, and typically contains the value “1.”

  • hashPrevBlock: This 32-byte field contains a 256-bit hash of the previous block header.

  • hashMerkleRoot: This 32-byte field contains a 256-bit hash of the root of the Merkle tree of all the transactions in the current block.

  • Time: This 4-byte field contains a timestamp of the current block that is used to situate it chronologically in the blockchain.

  • Bits: This 4-byte field contains the target difficulty of the current Bitcoin block which determines how difficult the target hash will be to find.

  • Nonce: This 4-byte field contains a 32-bit number that a miner must alter in order to correctly solve the computational puzzle for the current block.

Bitcoin miners compete to solve a computationally-intensive Proof-of-Work (PoW) puzzle. The puzzle requires taking all of the network’s transactions as well as information from the previous block (i.e. its block header), and “hashing” them using the SHA-256 algorithm. The first miner to complete this puzzle is allowed to create a new block, and receives a reward of newly minted BTC in return.

Generally speaking, hashing is a process whereby a specific input — in this case, recent transaction data and the block header — is entered into an algorithm to generate a specific type of output. A miner must take this input and guess a number called a “nonce” that, when entered into a SHA-256 hash, will generate one output that corresponds to another output set up by the Bitcoin protocol. Mining boils down to guessing nonces as quickly as possible. If a miner hits the specified output threshold, they will broadcast the new block (which includes their nonce) to other miners on the network so that they can hash it themselves and verify the proposed solution. If a majority of miners — 51% or more — reach consensus on the solution, the miner will be allowed to add their new block to the blockchain and receive the block reward. This same process repeats every 10 minutes on the Bitcoin network as new blocks are added and the data chain grows.

The Bitcoin block height measures how many blocks have preceded it on the Bitcoin protocol. For example, the next Bitcoin block halving (of mining rewards) will occur at a block height of 840,000 in 2024. In other words, this milestone will occur when the number of Bitcoin blocks written to the protocol since the genesis block in 2009 equals 840,000.

Transaction Data Within a Bitcoin Block

The other main component of a Bitcoin block is the transaction data, which makes up the majority of information inside the blockchain block data structure. The first transaction contained within each new block is known as a generation transaction, or coinbase transaction (not to be confused with the cryptocurrency exchange Coinbase), and is responsible for the generation of new BTC as part of the block reward for the successful miner. This initial transaction clearly specifies which Bitcoin addresses are entitled to receive the block reward.

Whereas traditional Bitcoin transactions contain both inputs and outputs, a generation transaction mints new BTC from the protocol itself. The rest of a block’s transaction data includes addresses of senders and receivers, the amount of BTC in each transaction, private key signatures authorizing the sending of BTC, and timestamps that cryptographically verify exactly when each transaction occurred. As mentioned previously the Bitcoin block size was historically limited to one MB of data. However, the Bitcoin network also supports a feature called “Segregated Witness” (SegWit) that enables transaction signature data to be segregated and compiled in an efficient manner — keeping the block at one MB while increasing block space for transaction data.

For each individual transaction, the following data is included:

  • Txin_count: This indicates the total number of transaction inputs.

  • Txins: This contains a list of all transaction inputs.

  • Txout_count: This indicates the total number of transaction outputs.

  • Txouts: This contains a list of all transaction outputs.

  • Script_witnesses: This contains a serialization of all the witness data for SegWit transactions.

  • Lock_time: This 4-byte field sets the block number or timestamp until the transaction is locked. It is typically set to zero, meaning that the transaction becomes valid immediately after the block is finalized.

The following transaction data is only included in SegWit transactions:

  • Version: This 4-byte field indicates the version number of the Bitcoin protocol being used, and typically contains the value “1.”

  • Marker: If present, this 1-byte field indicates that the transaction uses SegWit and contains the value “0x00.” If the transaction does not use SegWit, this field contains the value “null.”

  • Flag: If present, this 1-byte field also indicates that the transaction uses SegWit and contains the value “0x01.” If the transaction does not use SegWit, this field contains the value “null.”

Senders broadcast their transaction data to the network, and miners competing to generate new Bitcoin blocks are incentivized to add individual transactions to their blocks due to the included transaction fees.

The Future of Bitcoin Block Production

Bitcoin’s implementation of blockchain technology relies on a relatively simple, yet elegant system of minting new blocks and maintaining network security. Although this particular exploration of block anatomy is specific to the Bitcoin blockchain, many other PoW networks employ a very similar blockchain block data structure. These networks may have some differences — such as different block sizes or block times — but their overall systems of miners, blocks, and blockchain architecture are generally the same.

Cryptopedia does not guarantee the reliability of the Site content and shall not be held liable for any errors, omissions, or inaccuracies. The opinions and views expressed in any Cryptopedia article are solely those of the author(s) and do not reflect the opinions of Gemini or its management. The information provided on the Site is for informational purposes only, and it does not constitute an endorsement of any of the products and services discussed or investment, financial, or trading advice. A qualified professional should be consulted prior to making financial decisions. Please visit our Cryptopedia Site Policy to learn more.

Is this article helpful?

Yes

No

Topics in article
Up Next