# How Bitcoin network hashrate is estimated

Have you ever wondered how to know how much mining hashpower is currently mining Bitcoin? There is a way to estimate without knowing all of the miners and details about their equipment (hint this is practically impossible).

### Quick Explanation

We know how often a block is being solved, and we can calculated the number of hashes (on average) it will take to solve a block (at the current difficulty). From this information we can estimate the total network hashrate (Hashes/second).

### Script

I know you just want a script to calculate it, so here is a python script. Usage: `$ btc_hashrate <blocks-24h> <current-difficulty>`

### Math Formulas

Let’s see how we arrive at:

Let’s say we know that in the last 24h 155 blocks have been solved, so `blocks24h = 155`

. We also know at 10 min block times, there should be an average of `blocksexpected = 144`

(note this indicates the difficulty is too low, since they are being solved more quickly).

We know the current difficulty is 7,184,404,942,701. The number of hashes to find a block (on average), also known as the ** work** ω required is:

Where the `hashmax`

is just the max 32 byte number or 2²⁵⁶, and `target`

is the current target, which is calculated from the difficulty as:

The `targetmax`

is the highest (and therefore easiest) hash that was considered valid in Bitcoin (the genesis block’s target), and was `0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff.`

Then, substituting these values, we can simplify:

We need to account for the actual block rate by multiplying the work with the actual rate `(actualblocks/expectedblocks) * work`

. We also need to divide by the number of seconds per block `600`

.

Substituting, this give us:

Using wolframalpha: