<blockquote>
<p><strong>How to get unconfirmed transactions [...]</strong></p>
</blockquote>
<p>To be notified of new unconfirmed transactions, to retrieve them and to make other nodes aware of blocks you have mined you will need to implement the Bitcoin peer to peer protocols as described at <a href="https://developer.bitcoin.org/reference/p2p_networking.html" rel="nofollow noreferrer">https://developer.bitcoin.org/reference/p2p_networking.html</a></p>
<blockquote>
<p><strong>[...] and make a block [...]</strong></p>
</blockquote>
<p>You say you already have written code that does this.</p>
<blockquote>
<p><strong>[...] and submit the proof of work</strong></p>
</blockquote>
<p>The proof of work is in the block header you produced, it's the hash you produced that is lower than the current network target.</p>
<p>You &quot;submit&quot; the block by using the Bitcoin peer to peer protocol to make peers aware that you have new block data they can retrieve. Essentially you send an <code>inv</code> message that lists your new block. Any interested peer can then send your node a request for that block.</p>
<p>If you are mining in a pool, you instead implement whichever network protocols are used by your chosen pool. For example <a href="https://braiins.com/stratum-v2" rel="nofollow noreferrer">stratum V2</a></p>
<p>Since you are doing this for learning purposes you should not do any of this on mainnet, but should probably do all this on the network designated for testing.</p>

CC BY-SA 4.0
2021-08-01T10:15:40.533Z
2021-08-01T10:55:12.270Z
2021-08-01T10:55:12.270Z
RedGrittyBrick
<p>I am trying to learn how mining is done in bitcoin , wrote a simple mining code in python that works fine on sample data set of raw json coming from <a href="https://btc.cryptoid.info/btc/block.dws?693649.htm" rel="nofollow noreferrer">https://btc.cryptoid.info/btc/block.dws?693649.htm</a>, but these are all mined blocks .</p>
<p>How to get unconfirmed transactions and make a block and submit the proof of work. I referred to below link but none of the links mentioned in the page are working.</p>
<p><a href="https://en.bitcoin.it/wiki/Getblocktemplate" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Getblocktemplate</a></p>
<p>This is purely for learning purpose, I am not trying to make money out of this mining .</p>
<p>Thanks In Advance.</p>

<proof-of-work><getblocktemplate>
How to get unconfirmed transactions
Shakti
# How to get unconfirmed transactions

(Asked by: username_0 on 2021-08-01)

I am trying to learn how mining is done in bitcoin , wrote a simple mining code in python that works fine on sample data set of raw json coming from <https://btc.cryptoid.info/btc/block.dws?693649.htm>, but these are all mined blocks .

How to get unconfirmed transactions and make a block and submit the proof of work. I referred to below link but none of the links mentioned in the page are working.

<https://en.bitcoin.it/wiki/Getblocktemplate>

This is purely for learning purpose, I am not trying to make money out of this mining .

Thanks In Advance.

**Tags:** proof-of-work, getblocktemplate


---

## 1 answers

### Answer by username_1 on 2021-08-01. Score: 1 | Accepted answer

> **How to get unconfirmed transactions [...]**

To be notified of new unconfirmed transactions, to retrieve them and to make other nodes aware of blocks you have mined you will need to implement the Bitcoin peer to peer protocols as described at <https://developer.bitcoin.org/reference/p2p_networking.html>

> **[...] and make a block [...]**

You say you already have written code that does this.

> **[...] and submit the proof of work**

The proof of work is in the block header you produced, it's the hash you produced that is lower than the current network target.

You "submit" the block by using the Bitcoin peer to peer protocol to make peers aware that you have new block data they can retrieve. Essentially you send an `inv` message that lists your new block. Any interested peer can then send your node a request for that block.

If you are mining in a pool, you instead implement whichever network protocols are used by your chosen pool. For example [stratum V2](https://braiins.com/stratum-v2)

Since you are doing this for learning purposes you should not do any of this on mainnet, but should probably do all this on the network designated for testing.


---

