Configuration
Configure the Bitcoin Indexer for optimal performance and customize metaprotocol settings.
Configuration file
The Bitcoin Indexer uses a TOML configuration file to control all aspects of operation. Create the configuration file:
Terminal
$nano ~/bitcoin-indexer/bitcoin-indexer/bitcoin-indexer-config.toml
Full configuration example
title="bitcoin-indexer-config.toml"
[storage]# Path to RocksDB data directoryworking_dir = "/home/bitcoin-indexer/bitcoin-indexer/rocksdb-chainstate"[metrics]# Enable Prometheus metricsenabled = trueprometheus_port = 9153[ordinals.db]# PostgreSQL connection for Ordinals datadatabase = "ordinals"host = "localhost"port = 5432username = "postgres"password = "postgres"[ordinals.meta_protocols.brc20]# Enable BRC-20 indexing within Ordinalsenabled = truelru_cache_size = 10000[ordinals.meta_protocols.brc20.db]# Separate database for BRC-20 datadatabase = "brc20"host = "localhost"port = 5432username = "postgres"password = "postgres"[runes]# LRU cache for Runes performancelru_cache_size = 10000[runes.db]# PostgreSQL connection for Runes datadatabase = "runes"host = "localhost"port = 5432username = "postgres"password = "postgres"[bitcoind]# Bitcoin Core connection settingsnetwork = "mainnet"rpc_url = "http://127.0.0.1:8332"rpc_username = "user"rpc_password = "password"zmq_url = "tcp://0.0.0.0:18543"[resources]# Resource allocationulimit = 2048cpu_core_available = 6memory_available = 16bitcoind_rpc_threads = 6bitcoind_rpc_timeout = 15
Configuration sections
Storage configuration
Controls where the indexer stores blockchain state:
[storage]working_dir = "/path/to/rocksdb-chainstate"# Optional: Set RocksDB specific optionsrocksdb_max_open_files = 10000rocksdb_cache_size = "8GB"
Storage performance
Use fast NVMe storage for the working directory. The indexer performs many random reads/writes during operation.
Database connections
Each metaprotocol can use a separate database for isolation:
[ordinals.db]database = "ordinals"host = "localhost"port = 5432username = "postgres"password = "postgres"# Optional connection pool settingsmax_connections = 50min_connections = 10connection_timeout = 30
Bitcoin node connection
Configure how the indexer connects to your Bitcoin node:
[bitcoind]network = "mainnet" # or "testnet", "regtest"rpc_url = "http://127.0.0.1:8332"rpc_username = "user"rpc_password = "password"zmq_url = "tcp://0.0.0.0:18543"# Optional: Custom RPC timeoutrpc_timeout = 30
Resource allocation
Optimize performance based on your hardware:
[resources]# File descriptor limitulimit = 2048# CPU cores to use for indexingcpu_core_available = 6# Memory in GBmemory_available = 16# Bitcoin RPC connection poolbitcoind_rpc_threads = 6bitcoind_rpc_timeout = 15
Metaprotocol-specific settings
Ordinals configuration
[ordinals]# Start indexing from specific height (optional)start_block = 767430# Enable inscription number calculationtrack_numbers = true# Cursed inscription handlingindex_cursed = true[ordinals.meta_protocols.brc20]enabled = true# Cache size for BRC-20 balance calculationslru_cache_size = 10000# Track all operations or just valid onesindex_invalid_operations = false
Runes configuration
[runes]# LRU cache for rune entrieslru_cache_size = 10000# Start block for runes (mainnet activation)start_block = 840000# Index unspendable runesindex_unspendable = true
API configuration
Configure the REST API server:
[api]# API server settingsenabled = trueport = 3000host = "0.0.0.0"# CORS settingscors_enabled = truecors_origins = ["*"]# Rate limitingrate_limit_enabled = truerate_limit_requests_per_minute = 60# API key authenticationrequire_auth = falseapi_keys = ["your-api-key-here"]
Monitoring configuration
Enable metrics and monitoring:
[metrics]enabled = trueprometheus_port = 9153# Log settings[logging]level = "info" # debug, info, warn, errorformat = "json" # json or prettydirectory = "/home/bitcoin-indexer/bitcoin-indexer/logs"max_size = "100MB"max_backups = 10
Performance tuning
For high-throughput indexing
[resources]cpu_core_available = 16memory_available = 32bitcoind_rpc_threads = 16[storage]rocksdb_cache_size = "16GB"rocksdb_max_open_files = 20000[ordinals.db]max_connections = 100
For limited resources
[resources]cpu_core_available = 4memory_available = 8bitcoind_rpc_threads = 4[storage]rocksdb_cache_size = "2GB"rocksdb_max_open_files = 5000[ordinals.db]max_connections = 20
Environment variables
Configuration values can be overridden with environment variables:
# Override database passwordexport BITCOIN_INDEXER_ORDINALS_DB_PASSWORD="secure_password"# Override RPC credentialsexport BITCOIN_INDEXER_BITCOIND_RPC_USERNAME="myuser"export BITCOIN_INDEXER_BITCOIND_RPC_PASSWORD="mypass"# Override API portexport BITCOIN_INDEXER_API_PORT="8080"
Validate configuration
Test your configuration before starting:
Terminal
$bitcoin-indexer validate --config-path=~/bitcoin-indexer/bitcoin-indexer/bitcoin-indexer-config.toml[32m✓[0m Configuration valid[32m✓[0m Bitcoin node reachable[32m✓[0m PostgreSQL databases accessible[32m✓[0m Storage directory writable