Block

From Bitcoin.com Wiki
Jump to: navigation, search

Bitcoin is an electronic peer-to-peer cash system.

Bitcoin enables people to electronically send value directly to each other.

How does this work?

Each time value is sent to another party that is a transaction.

Bitcoin records these transactions in blocks.

A block is a record of some or all of the most recent Bitcoin transactions that have not yet been recorded in any prior blocks.

They could be thought of like the individual pages of a city recorder's record book (where changes to title to real estate are recorded) or a stock transaction ledger.

New blocks are added to the end of the record (known as the block chain), and can never be changed or removed once written

Each block memorializes what took place in the minutes before it was created.

Description

Each block contains, among other things, a record of some (blocks have size caps) or all recent transactions, and a reference to the block that came immediately before it. It also contains an answer to a difficult-to-solve mathematical puzzle - the answer to which is unique to each block. New blocks cannot be submitted to the network without the correct answer - the process of "mining" is essentially the process of competing to be the next to find the answer that "solves" the current block. The mathematical problem in each block is extremely difficult to solve, but once a valid solution is found, it is easy and fast for the rest of the network to confirm that the solution is correct. There are multiple valid solutions for any given block - only one of the solutions needs to be found for the block to be solved.

Each block also contains a generation transaction (commonly known as a coinbase transaction. The coinbase transaction is always the first transaction appearing in every block. Whoever mines the block decides which bitcoin addresses or scripts to send the block reward to. The block reward size started at 50 and is halved every 210,000 blocks (about four years). The block reward is currently 25 bitcoins.

Here is a live block reward transaction.

Why are there block rewards and why do they shrink?

For bitcoin to be valuable the network needs to be secure. For the network to be secure miners need an incentive to mine. Bitcoin also has a distribution problem - how will the 21 million coins be distributed? Block rewards solve both problems. The block reward distributes bitcoins to owners and gives miners an economic incentive until transaction fees support mining costs. Why does the reward shrink over time? Unlike most currencies bitcoin is designed with a fixed cap of 21 million coins. Having a cap requires the distribution of new coins to stop and the halving mechanism is a good way to do this. Early miners who are taking on risk the currency wouldn't succeed are compensated with more bitcoins in the block reward than miners who join later.

Bitcoin transactions are broadcast to the network by the sender, and all peers trying to solve blocks collect the transaction records and add them to the block they are working to solve. Miners get incentive to include transactions in their blocks because each transaction contains a transaction fee.

How is a new block created every ten minutes?

One of the goals of bitcoin is to have a secure network. Security is obtained by solving a difficult math puzzle. If the problem is too easy for the number of miners working on it the blocks would be found quickly. If the problem is too hard blocks will be found too slowly. The bitcoin network adjusts the difficulty of the math puzzle every two weeks to maintain the ten minute time interval.

Every 2016 blocks (solved in about two weeks), all Bitcoin clients compare the actual number created with this goal and modify the target by the percentage that it varied. The network comes to a consensus and automatically increases (or decreases) the difficulty of generating blocks.

Because each block contains a reference to the prior block, the collection of all blocks in existence can be said to form a chain. However, it's possible for the chain to have temporary splits - for example, if two miners arrive at two different valid solutions for the same block at the same time, unbeknownst to one another. The peer-to-peer network is designed to resolve these splits within a short period of time, so that only one branch of the chain survives.

The client accepts the 'longest' chain of blocks as valid. The 'length' of the entire block chain refers to the chain with the most combined difficulty, not the one with the most blocks. This prevents someone from forking the chain and creating a large number of low-difficulty blocks, and having it accepted by the network as 'longest'.


Block structure

Field Description Size
Magic no value always 0xD9B4BEF9 4 bytes
Blocksize number of bytes following up to end of block 4 bytes
Blockheader consists of 6 items 80 bytes
Transaction counter positive integer VI = VarInt 1 - 9 bytes
transactions the (non empty) list of transactions <Transaction counter>-many transactions


Common Questions about Blocks

How many blocks are there?

Current block count

What stops miners from giving themselves bitcoin?

All the miners validate each other's work. If a miner tried to give themselves additional bitcoins beyond the allowed block reward, the other miners, and therefore the bitcoin network, would reject the block.

What is the maximum number of blocks?

There is no maximum number, blocks just keep getting added to the end of the chain at an average rate of one every 10 minutes.

Even when all 21 million coins have been generated?

Yes. The blocks are for proving that transactions existed at a particular time. Transactions will still occur once all the coins have been generated, so blocks will still be created as long as people are trading Bitcoins.

How long will it take me to generate a block?

No-one can say exactly. There is a generation calculator that will tell you how long it might take.

What if I'm 1% towards calculating a block and...?

There's no such thing as being 1% towards solving a block. You don't make progress towards solving it. After working on it for 24 hours, your chances of solving it are equal to what your chances were at the start or at any moment. Believing otherwise is what's known as the Gambler's fallacy [1].

It's like trying to flip 53 coins at once and have them all come up heads. Each time you try, your chances of success are the same.

Where can I find more technical detail?

There is more technical detail on the block hashing algorithm page.

What was the first block?

Blocks started forming on the blockchain on January 3, 2009 when Satoshi Nakamoto created the first block called the Genesis Block.