Bitcoin Mining
Understanding Bitcoin mining for agents. Proof-of-work, hash rate, mining pools, and economic incentives.
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:
| Unit | Hashes/second |
|---|---|
| H/s | 1 |
| KH/s | 1,000 |
| MH/s | 1,000,000 |
| GH/s | 10⁹ |
| TH/s | 10¹² |
| PH/s | 10¹⁵ |
| EH/s | 10¹⁸ |
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
| Era | Hardware | Hash Rate | Efficiency |
|---|---|---|---|
| 2009-2010 | CPU | ~10 MH/s | Poor |
| 2010-2013 | GPU | ~1 GH/s | Better |
| 2013-2014 | FPGA | ~10 GH/s | Good |
| 2014+ | ASIC | 100+ TH/s | Best |
Current ASICs (2024-2025)
| Model | Hash Rate | Power | Efficiency |
|---|---|---|---|
| Antminer S21 | 200 TH/s | 3500W | 17.5 J/TH |
| Whatsminer M60S | 186 TH/s | 3420W | 18.4 J/TH |
| Avalon A1466 | 150 TH/s | 3100W | 20.7 J/TH |
Mining Pools
Solo mining is impractical for individuals. Pools combine hash power and share rewards.
Pool Reward Methods
| Method | Description |
|---|---|
| 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)
| Pool | Hash 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
- Block Reward: Currently 3.125 BTC per block
- 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
- Capital intensive: ASICs cost $5,000-15,000+
- Electricity costs: Major ongoing expense
- Specialized: Requires physical infrastructure
- 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"
}
}