<blockquote>
<p><strong>information about the current block the world try to mine</strong></p>
</blockquote>
<p>The world is concurrently trying to mine many different blocks which only have the block height and target (bits/difficulty) in common and therefore have a common prior block hash.</p>
<blockquote>
<p><strong>(I mean Version, Previous Block, Merkle Root, Time, Bits)</strong></p>
</blockquote>
<p>Although <code>previous block</code> and <code>bits</code> are common to all concurrent mining effort globally, <code>version</code>, <code>Merkle root</code> and <code>time</code> are things effectively chosen by individual miners (or pools) and therefore differ from miner to miner.</p>
<p>To get the target and the hash of the top block, you need to interrogate either a node that you run (e.g. Bitcoin core as vincenzopalazzo suggested) or a public node such as a blockchain explorer. Both have APIs but the APIs differ. There may be Python libraries you can use but which libraries you should use, if any, will depend on which source you select.</p>
<p>Bitcoin core's API has functions useful for constructing block templates.</p>
<blockquote>
<p><strong>plus how many zeros we are looking for for the output of the hash!</strong></p>
</blockquote>
<p>None. Bitcoin does not ever consider the number of leading zeroes. Adam Black's &quot;HashCash&quot; unimplemented proposal used number of binary leading zeroes but Nakamoto's &quot;Bitcoin&quot; did something different though partially inspired by Hashcash.</p>
<p>The test in Bitcoin is a simple numeric comparison of <code>hash &lt;= target</code> where the target is obtained by expanding the <code>bits</code> you mentioned before and recalculating the next value when appropriate (when block height is a multiple of 2016).</p>

CC BY-SA 4.0
2023-10-03T09:57:37.263Z
2023-10-03T10:08:51.930Z
2023-10-03T10:08:51.930Z
RedGrittyBrick
<p>To take the information of the bitcoin blockchain, you can use the bitcoin core RPC Framework, for use it, you must have all blockchain on your computer</p>

<ol>
<li>Download <a href="https://bitcoin.org/en/bitcoin-core/" rel="nofollow noreferrer">Bitcoin core</a></li>
<li>aligns the bitcoin node</li>
<li>Configure rpc framework</li>
<li>Use the <a href="https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)" rel="nofollow noreferrer">API</a> to take the information, I prefer using this <a href="https://github.com/jgarzik/python-bitcoinrpc" rel="nofollow noreferrer">library</a> with python, <a href="https://gist.github.com/vincenzopalazzo/1f1245ab200ed59a0604dee134f42863" rel="nofollow noreferrer">this</a> is an example for using it</li>
</ol>

<p>You can use <a href="https://bitcoincore.org/en/doc/0.18.0/" rel="nofollow noreferrer">this documentation</a> for study API</p>

<p>also for a response to the last comment, you can use the API for call the Mining commands but is difficult understand your question "I can print information about the block they're mining now" because the mining is a war for the node and each node can have different information</p>

CC BY-SA 4.0
2019-09-25T22:57:37.023Z
Is it oblige to do steps 1 and 2 and 3? Couldn't I use the API directly?
Prometheus
CC BY-SA 4.0
2019-09-25T22:58:38.297Z
What are the names of functions that I can get information with them?
Prometheus
CC BY-SA 4.0
2019-09-23T16:10:57.107Z
2019-09-23T16:22:34.660Z
2019-09-23T16:22:34.660Z
vincenzopalazzo
<p>What is the program in Python that print information about the current block the world try to mine (I mean Version, Previous Block, Merkle Root, Time, Bits) plus how many zeros we are looking for for the output of the hash!</p>

CC BY-SA 4.0
2019-09-23T13:02:08.390Z
Do you have a need to a parser for file blk?
vincenzopalazzo
CC BY-SA 4.0
2019-09-23T15:48:09.533Z
@vincenzopalazzo I don't understand what do you mean!
Prometheus
CC BY-SA 4.0
2019-09-23T15:54:22.943Z
What are you looking for? where do you want to get that information from?
vincenzopalazzo
CC BY-SA 4.0
2019-09-23T16:00:32.553Z
@vincenzopalazzo I think that I could get them from a library. How do mining programs get these information?
Prometheus
CC BY-SA 4.0
2019-09-23T16:03:10.653Z
From the bitcoin RPC Framework
vincenzopalazzo
CC BY-SA 4.0
2019-09-23T16:13:09.520Z
@vincenzopalazzo And can't I get the same from this framework in Python so I can print information about the block they're mining now?
Prometheus
CC BY-SA 4.0
2019-09-23T16:23:00.437Z
I have tried to add an answer to the question
vincenzopalazzo
<blockchain><python>
What is the program in Python that print information about the current block?
Prometheus
# What is the program in Python that print information about the current block?

(Asked by: username_0 on 2019-09-23)

What is the program in Python that print information about the current block the world try to mine (I mean Version, Previous Block, Merkle Root, Time, Bits) plus how many zeros we are looking for for the output of the hash!

**Tags:** blockchain, python

> **Comments:**
> **username_1**: Do you have a need to a parser for file blk?  
> **username_0**: @username_1 I don't understand what do you mean!  
> **username_1**: What are you looking for? where do you want to get that information from?  
> **username_0**: @username_1 I think that I could get them from a library. How do mining programs get these information?  
> **username_1**: From the bitcoin RPC Framework  
> **username_0**: @username_1 And can't I get the same from this framework in Python so I can print information about the block they're mining now?  
> **username_1**: I have tried to add an answer to the question  

---

## 2 answers

### Answer by username_2 on 2023-10-03. Score: 0

> **information about the current block the world try to mine**

The world is concurrently trying to mine many different blocks which only have the block height and target (bits/difficulty) in common and therefore have a common prior block hash.

> **(I mean Version, Previous Block, Merkle Root, Time, Bits)**

Although `previous block` and `bits` are common to all concurrent mining effort globally, `version`, `Merkle root` and `time` are things effectively chosen by individual miners (or pools) and therefore differ from miner to miner.

To get the target and the hash of the top block, you need to interrogate either a node that you run (e.g. Bitcoin core as username_1 suggested) or a public node such as a blockchain explorer. Both have APIs but the APIs differ. There may be Python libraries you can use but which libraries you should use, if any, will depend on which source you select.

Bitcoin core's API has functions useful for constructing block templates.

> **plus how many zeros we are looking for for the output of the hash!**

None. Bitcoin does not ever consider the number of leading zeroes. Adam Black's "HashCash" unimplemented proposal used number of binary leading zeroes but Nakamoto's "Bitcoin" did something different though partially inspired by Hashcash.

The test in Bitcoin is a simple numeric comparison of `hash <= target` where the target is obtained by expanding the `bits` you mentioned before and recalculating the next value when appropriate (when block height is a multiple of 2016).


---

### Answer by username_1 on 2019-09-23. Score: 0

To take the information of the bitcoin blockchain, you can use the bitcoin core RPC Framework, for use it, you must have all blockchain on your computer

1. Download [Bitcoin core](https://bitcoin.org/en/bitcoin-core/)
2. aligns the bitcoin node
3. Configure rpc framework
4. Use the [API](https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)) to take the information, I prefer using this [library](https://github.com/jgarzik/python-bitcoinrpc) with python, [this](https://gist.github.com/username_1/1f1245ab200ed59a0604dee134f42863) is an example for using it

You can use [this documentation](https://bitcoincore.org/en/doc/0.18.0/) for study API

also for a response to the last comment, you can use the API for call the Mining commands but is difficult understand your question "I can print information about the block they're mining now" because the mining is a war for the node and each node can have different information

> **Comments:**
> **username_0**: Is it oblige to do steps 1 and 2 and 3? Couldn't I use the API directly?  
> **username_0**: What are the names of functions that I can get information with them?  

---

