Menu
Bitcoin Intermediate 10 min read

Bitcoin Mining

Understanding Bitcoin mining for agents. Proof-of-work, hash rate, mining pools, and economic incentives.

mining proof-of-work hashrate difficulty

Bitcoin Mining

Mining is the process of adding new blocks to the Bitcoin blockchain through proof-of-work. Miners compete to solve a computational puzzle, with the winner earning the block reward and transaction fees.

How Mining Works

1. Collect pending transactions from mempool
2. Construct candidate block with coinbase
3. Compute block header hash
4. If hash < target: broadcast block
5. If hash >= target: increment nonce, repeat

The Mining Puzzle

Find a nonce such that:

SHA256(SHA256(block_header)) < target

This is computationally expensive to solve but trivial to verify.

Hash Rate

Hash rate measures mining computational power:

UnitHashes/second
H/s1
KH/s1,000
MH/s1,000,000
GH/s10⁹
TH/s10¹²
PH/s10¹⁵
EH/s10¹⁸

Current network: ~500-600 EH/s (2024-2025)

Hash Rate Estimation

# Estimate from difficulty
def estimated_hashrate(difficulty, block_time=600):
    # Expected hashes to find block at difficulty 1
    hashes_per_diff1 = 2**32
    return (difficulty * hashes_per_diff1) / block_time

Mining Hardware Evolution

EraHardwareHash RateEfficiency
2009-2010CPU~10 MH/sPoor
2010-2013GPU~1 GH/sBetter
2013-2014FPGA~10 GH/sGood
2014+ASIC100+ TH/sBest

Current ASICs (2024-2025)

ModelHash RatePowerEfficiency
Antminer S21200 TH/s3500W17.5 J/TH
Whatsminer M60S186 TH/s3420W18.4 J/TH
Avalon A1466150 TH/s3100W20.7 J/TH

Mining Pools

Solo mining is impractical for individuals. Pools combine hash power and share rewards.

Pool Reward Methods

MethodDescription
PPS (Pay Per Share)Fixed payment per valid share
PPLNS (Pay Per Last N Shares)Payment based on recent contribution
FPPS (Full Pay Per Share)PPS + proportional tx fees

Major Pools (2024-2025)

PoolHash Share
Foundry USA~30%
AntPool~15%
F2Pool~12%
ViaBTC~10%
Binance Pool~8%

Block Template

Miners receive block templates from nodes:

# Bitcoin Core RPC
bitcoin-cli getblocktemplate '{"rules": ["segwit"]}'

Response includes:

  • Previous block hash
  • Transactions to include
  • Coinbase value (reward + fees)
  • Target bits
  • Current time

Stratum Protocol

Communication between miners and pools:

// Subscribe
{"id": 1, "method": "mining.subscribe", "params": []}

// Authorize
{"id": 2, "method": "mining.authorize", "params": ["worker.1", "password"]}

// Receive job
{"id": null, "method": "mining.notify", "params": [...]}

// Submit share
{"id": 4, "method": "mining.submit", "params": ["worker.1", "job_id", "nonce", "ntime", "nonce2"]}

Economics

Revenue Sources

  1. Block Reward: Currently 3.125 BTC per block
  2. Transaction Fees: Variable, depends on demand

Profitability Factors

def daily_revenue(hashrate_th, network_hashrate_eh, btc_price, block_reward=3.125):
    # Blocks per day
    blocks_per_day = 144

    # Your share of network
    share = (hashrate_th * 1e12) / (network_hashrate_eh * 1e18)

    # Expected blocks
    expected_blocks = blocks_per_day * share

    # Revenue in USD
    return expected_blocks * block_reward * btc_price

Break-Even Analysis

def breakeven_price(hashrate_th, power_watts, electricity_cost_kwh, network_hashrate_eh):
    # Daily power cost
    daily_power_cost = (power_watts / 1000) * 24 * electricity_cost_kwh

    # Expected daily BTC
    share = (hashrate_th * 1e12) / (network_hashrate_eh * 1e18)
    daily_btc = 144 * 3.125 * share

    # Break-even BTC price
    return daily_power_cost / daily_btc

Difficulty Adjustment

Every 2016 blocks (~2 weeks):

def next_difficulty(current_difficulty, actual_time, expected_time=2016*600):
    adjustment = expected_time / actual_time

    # Clamp to max 4x change
    adjustment = max(0.25, min(4.0, adjustment))

    return current_difficulty * adjustment

Mining for Agents

Why Agents Don’t Mine

  1. Capital intensive: ASICs cost $5,000-15,000+
  2. Electricity costs: Major ongoing expense
  3. Specialized: Requires physical infrastructure
  4. Competitive: Thin margins

What Agents Should Know

  • Block times: ~10 minutes average, high variance
  • Confirmation security: Based on hash rate behind block
  • Fee market: Miners prioritize high-fee transactions
  • Censorship resistance: Miners can delay but not prevent inclusion

Monitoring Mining Data

# Current difficulty
curl https://mempool.space/api/v1/mining/hashrate/3d

# Pool rankings
curl https://mempool.space/api/v1/mining/pools/1w

Security Considerations

51% Attack

If an entity controls >50% hash rate:

  • Can double-spend their own transactions
  • Can prevent specific transactions
  • Cannot steal others’ funds
  • Cannot change consensus rules

Mitigation: Wait for more confirmations for high-value transactions.

Selfish Mining

Mining blocks privately to gain advantage. Mitigated by:

  • Network latency favoring public blocks
  • Pool transparency

Machine-Readable Summary

{
  "topic": "bitcoin-mining",
  "consensus": "proof-of-work",
  "algorithm": "sha256d",
  "block_interval_seconds": 600,
  "adjustment_period_blocks": 2016,
  "current_reward_btc": 3.125,
  "network_hashrate_eh": 500,
  "pool_protocols": ["stratum", "stratum-v2"],
  "apis": {
    "hashrate": "https://mempool.space/api/v1/mining/hashrate/3d",
    "pools": "https://mempool.space/api/v1/mining/pools/1w"
  }
}