<p>When miners try to compute a block, they pick all transactions that they want to be added in the block, plus one coinbase (generation) transaction to their address. They may include any transaction they want to form a tree of transactions later hashed into the merkle root and referenced into the block's header.</p>

<p>It is to note that for a block to be accepted by the network it needs to contain only valid transactions: inputs that are not yet spent, inputs that have the valid ammount, signature that verifies ok and etc...</p>

<p>After having a valid merkle root they build the block's header:</p>

<ul>
<li>Version (4 bytes)</li>
<li>Hash of the previous block, thus making a chain of block (32 bytes)</li>
<li>Merkle root, the tree of transactions' reference (32 bytes)</li>
<li>Timestamp, number of seconds since 1970-01-01 00:00 (4 bytes)</li>
<li>Bits, a representation of the networks current difficulty (4 bytes)</li>
<li>Nonce, incremented when mining (4 bytes)</li>
</ul>

<p>See more <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm">here</a> to learn more on how to build the header.</p>

<p>Then this where your miner enters the game. It starts with the nonce at 0, hash (sha-256 2x) the block's header and then check if the hash in under the <a href="http://blockexplorer.com/q/hextarget">current target</a> (if you are on a pool the share target). If not it increments the nonce and hash again. If the hash is under the <a href="http://blockexplorer.com/q/hextarget">current target</a> YOU FOUND A BLOCK, you then transfer your block's header and the associated transactions' tree and the network accepts it. Because you had a coinbase transaction in your block paying to your bitcoin address those bitcoin then becomes yours.</p>

<p>It is to says that finding a block is rare so your miner will eventually run out of nonce to use you can then change parameter in your block header (more likely the timestamp) or add a extra nonce field in your transactions tree thus changing the merkle root.</p>

<p>As for which transactions are chosen to be part of a block, it is mostly the miners choice to include one or other transaction. But normally they would include transaction with a miners fee in it to gain more bitcoin, a miner could also choose not to include any transaction and only get the coinbase one. The propagation of ones transaction through the network also influence which transactions a miner do include.</p>

CC BY-SA 3.0
2013-01-28T08:44:29.837Z
How do they select which transactions ?? Is there some tool liek a block chain viewer ??
BitCoin New Guy
CC BY-SA 3.0
2013-01-28T08:56:05.597Z
Yes there is one http://blockexplorer.com, but actually all nodes on the network are there to relay transaction, miner will include (normally) all transaction they received. All nodes (bitcoin standard client) also has the full blockchain.
Gopoi
CC BY-SA 3.0
2013-01-28T08:40:03.067Z
2013-01-28T08:40:03.067Z
Gopoi
<p>have been mining on pools and blindly going a long for the ride of </p>

<p><strong>> generating a block</strong></p>

<p>Can somebody walk through the process in simple terms of the steps involved in creating a block on the blockchain ?</p>

<p>What determines what transactions get included on the block we are mining ?</p>

<blockchain><block><block-header><transaction-selection><mining-technical-details>
Whats the process of Creating a Block on the BlockChain
BitCoin New Guy
# Whats the process of Creating a Block on the BlockChain

(Asked by: username_0 on 2013-01-28)

have been mining on pools and blindly going a long for the ride of

**> generating a block**

Can somebody walk through the process in simple terms of the steps involved in creating a block on the blockchain ?

What determines what transactions get included on the block we are mining ?

**Tags:** blockchain, block, block-header, transaction-selection, mining-technical-details


---

## 1 answers

### Answer by username_1 on 2013-01-28. Score: 11 | Accepted answer

When miners try to compute a block, they pick all transactions that they want to be added in the block, plus one coinbase (generation) transaction to their address. They may include any transaction they want to form a tree of transactions later hashed into the merkle root and referenced into the block's header.

It is to note that for a block to be accepted by the network it needs to contain only valid transactions: inputs that are not yet spent, inputs that have the valid ammount, signature that verifies ok and etc...

After having a valid merkle root they build the block's header:

* Version (4 bytes)
* Hash of the previous block, thus making a chain of block (32 bytes)
* Merkle root, the tree of transactions' reference (32 bytes)
* Timestamp, number of seconds since 1970-01-01 00:00 (4 bytes)
* Bits, a representation of the networks current difficulty (4 bytes)
* Nonce, incremented when mining (4 bytes)

See more [here](https://en.username_0.it/wiki/Block_hashing_algorithm) to learn more on how to build the header.

Then this where your miner enters the game. It starts with the nonce at 0, hash (sha-256 2x) the block's header and then check if the hash in under the [current target](http://blockexplorer.com/q/hextarget) (if you are on a pool the share target). If not it increments the nonce and hash again. If the hash is under the [current target](http://blockexplorer.com/q/hextarget) YOU FOUND A BLOCK, you then transfer your block's header and the associated transactions' tree and the network accepts it. Because you had a coinbase transaction in your block paying to your username_0 address those username_0 then becomes yours.

It is to says that finding a block is rare so your miner will eventually run out of nonce to use you can then change parameter in your block header (more likely the timestamp) or add a extra nonce field in your transactions tree thus changing the merkle root.

As for which transactions are chosen to be part of a block, it is mostly the miners choice to include one or other transaction. But normally they would include transaction with a miners fee in it to gain more username_0, a miner could also choose not to include any transaction and only get the coinbase one. The propagation of ones transaction through the network also influence which transactions a miner do include.

> **Comments:**
> **username_0**: How do they select which transactions ?? Is there some tool liek a block chain viewer ??  
> **username_1**: Yes there is one http://blockexplorer.com, but actually all nodes on the network are there to relay transaction, miner will include (normally) all transaction they received. All nodes (username_0 standard client) also has the full blockchain.  

---

