All packages

bitcoin-esplora-enhanced

PaulieB14
v0.2.1/6 downloads/Repository

Package ref

bitcoin-esplora-enhanced@v0.2.1

Run package

CLI

Run map_block_esplora from the command line.

substreams run bitcoin-esplora-enhanced@v0.2.1 map_block_esplora -e bitcoin --start-block -1
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

Bitcoin Esplora Enhanced Substream

Enhanced Bitcoin blockchain data processor providing Esplora API compatible output using Substreams.

Features

  • Block Metadata: Hash, height, timestamp, difficulty, merkle root, previous hash
  • Transaction Details: Full transaction data with inputs, outputs, and witness data
  • Address Tracking: UTXO tracking per address with funded/spent counts
  • Network Statistics: Fee estimates, active addresses, total fees per block
  • SQL Sink Ready: PostgreSQL and ClickHouse schemas included

Modules

ModuleOutputDescription
map_block_esploraBlockEsploraBlock metadata in Esplora format
map_transactions_esploraTransactionsEsploraAll transactions with inputs/outputs/witness
map_addresses_esploraAddressesEsploraAddress analysis and UTXO tracking
map_network_statsNetworkStatsNetwork statistics and fee estimates

Quick Start

Prerequisites

# Install Substreams CLI
brew install streamingfast/tap/substreams

# Authenticate
substreams auth

Run

# Stream block data
substreams run -e btc.substreams.pinax.network:443 \
  https://github.com/PaulieB14/Bitcoin-Explorer-Substream/releases/download/v0.2.0/bitcoin-esplora-enhanced-v0.2.0.spkg \
  map_block_esplora -s 800000 -t +10

# Stream transactions
substreams run -e btc.substreams.pinax.network:443 \
  https://github.com/PaulieB14/Bitcoin-Explorer-Substream/releases/download/v0.2.0/bitcoin-esplora-enhanced-v0.2.0.spkg \
  map_transactions_esplora -s 800000 -t +10

Build from Source

git clone https://github.com/PaulieB14/Bitcoin-Explorer-Substream.git
cd Bitcoin-Explorer-Substream
make build
make pack

SQL Sink Usage

PostgreSQL

# Setup database
substreams-sink-sql setup \
  "psql://user:pass@localhost:5432/bitcoin" \
  ./sql/schema-postgres.sql

# Run sink
substreams-sink-sql run \
  "psql://user:pass@localhost:5432/bitcoin" \
  bitcoin-esplora-enhanced-v0.2.0.spkg \
  map_block_esplora

ClickHouse

# Setup database
substreams-sink-sql setup \
  "clickhouse://user:pass@localhost:9000/bitcoin" \
  ./sql/schema-clickhouse.sql

# Run sink
substreams-sink-sql run \
  "clickhouse://user:pass@localhost:9000/bitcoin" \
  bitcoin-esplora-enhanced-v0.2.0.spkg \
  map_block_esplora

Output Examples

Block Data

{
  "id": "00000000000000000002a7c4c1e48d76c5a37902165a270156b7a8d72728a054",
  "height": 800000,
  "version": 536870912,
  "timestamp": 1690168629,
  "tx_count": 3721,
  "size": 1621583,
  "weight": 3993561,
  "merkle_root": "...",
  "previous_hash": "...",
  "difficulty": 53911173001054.59
}

Transaction Data

{
  "txid": "abc123...",
  "version": 2,
  "locktime": 0,
  "size": 225,
  "weight": 573,
  "fee": 4500,
  "inputs": [...],
  "outputs": [...],
  "witness": ["304402...", "0279be..."],
  "status": {
    "confirmed": true,
    "block_height": 800000
  }
}

Limitations

  • Mempool Data: Substreams processes finalized blocks only. Real-time mempool data requires a separate Bitcoin node connection.
  • Fee Calculation: Accurate fees require UTXO lookup. Current implementation provides estimates based on transaction characteristics.

Development

# Check code
make check

# Format code
make fmt

# Run tests
make test-unit

# Clean build
make clean

License

Apache 2.0

Links

Modules

Execution graph

4 modules