Bitcoin SV blockchain explorer and data sync tool
Bitblocks is a Phoenix/Elixir application that syncs Bitcoin SV blockchain data from a Bitcoin SV node and provides a web interface to explore blocks and transactions. It connects to a BSV node via RPC, stores blockchain data in PostgreSQL, and serves it through Phoenix LiveView.
- Blockchain Sync: Efficiently sync blocks and transactions from a Bitcoin SV node
- Web Explorer: Browse blocks and transactions through a clean web interface
- Phoenix LiveView: Real-time, interactive UI without complex JavaScript
- PostgreSQL Storage: Reliable storage of blockchain data with optimized indexes
- RPC Integration: Direct connection to Bitcoin SV node via JSON-RPC
- Bitcoin SV Full Node with RPC access (required - this app syncs directly from a node)
- Elixir 1.18 or later
- Phoenix 1.7.11
- PostgreSQL (any recent version)
- Node.js (for asset compilation)
-
Clone the repository
git clone https://github.com/afomi/bitblocks.git cd bitblocks -
Install dependencies
mix deps.get
-
Configure your Bitcoin SV node connection
Set environment variables for your Bitcoin SV node:
export BITCOIN_NODE_URL=http://your-node-ip:8332 export BITCOIN_NODE_RPC_USERNAME=your_rpc_username export BITCOIN_NODE_RPC_PASSWORD=your_rpc_password export BITCOIN_NODE_RPC_URL=http://your-node-ip:8332
-
Setup the database
mix ecto.create mix ecto.migrate
-
Install and build assets
mix assets.setup mix assets.build
Start the Phoenix server:
mix phx.serverOr start it inside IEx (Interactive Elixir) for debugging and manual operations:
iex -S mix phx.serverVisit http://localhost:4000 to view the web interface.
Note: The web interface includes a sync dashboard at http://localhost:4000/sync for managing blockchain synchronization through the UI.
Use IEx to sync blockchain data from your Bitcoin SV node:
# Start the server with IEx
iex -S mix phx.server
# Sync blocks 0-1000
Bitblocks.Sync.get_blocks(0..1000)
# Sync a specific range
Bitblocks.Sync.get_blocks(100_000..200_000)
# Get full transaction data for a specific block
Bitblocks.Sync.get(100)The sync process works in two stages:
get_blocks/1- Fetches block metadata and transaction IDsget/1- Fetches full raw transaction data for each transaction in the block
Once synced, you can browse the data:
- Status Page:
http://localhost:4000/status - Blocks List:
http://localhost:4000/blocks - Block Details:
http://localhost:4000/blocks/:height_or_hash - Transactions List:
http://localhost:4000/transactions - Transaction Details:
http://localhost:4000/transactions/:txid
mix ecto.create # Create database
mix ecto.migrate # Run migrations
mix ecto.reset # Drop, recreate, and migrate database# Run all tests (excluding accessibility tests that require ChromeDriver)
mix test
# Run accessibility tests (requires ChromeDriver)
mix test --only accessibility_axe
# Run with visible browser for debugging
HEADLESS=false mix test --only accessibility_axeAccessibility Testing Requirements:
- ChromeDriver must be installed:
brew install chromedriver(macOS) - See
test/bitblocks_web/ACCESSIBILITY.mdfor full documentation
mix assets.build # Build Tailwind CSS and esbuild
mix assets.deploy # Build and minify for productionThe application requires access to a Bitcoin SV node with RPC enabled. Configure your node in bitcoin.conf:
server=1
rpcuser=your_username
rpcpassword=your_secure_password
rpcallowip=your_app_ip
BITCOIN_NODE_URL- Bitcoin SV node URL (e.g.,http://localhost:8332)BITCOIN_NODE_RPC_USERNAME- RPC usernameBITCOIN_NODE_RPC_PASSWORD- RPC passwordBITCOIN_NODE_RPC_URL- RPC endpoint URL (usually same as BITCOIN_NODE_URL)
Bitblocks includes configuration for deployment to Fly.io:
-
Install Fly.io CLI
curl -L https://fly.io/install.sh | sh -
Create a Fly.io app
fly apps create your-app-name
-
Update fly.toml
Edit
fly.tomland change the app name:app = 'your-app-name'
Update
PHX_HOSTin the[env]section:PHX_HOST = 'your-app-name.fly.dev'
-
Set secrets
fly secrets set SECRET_KEY_BASE=$(mix phx.gen.secret) fly secrets set BITCOIN_NODE_URL=http://your-node:8332 fly secrets set BITCOIN_NODE_RPC_USERNAME=your_username fly secrets set BITCOIN_NODE_RPC_PASSWORD=your_password fly secrets set DATABASE_URL=your_postgres_url
-
Deploy
fly deploy
The project includes automated testing and deployment:
On every push and PR:
- Runs unit tests
- Runs accessibility tests (axe-core)
- Compiles with warnings-as-errors
On push to develop:
- Runs all tests first
- Automatically deploys to Fly.io if tests pass
Setup:
- Get your Fly.io API token:
fly auth token - Add it to GitHub: Repository → Settings → Secrets and variables → Actions
- Create secret named
FLY_API_TOKENwith your token
See .github/workflows/ci.yml for the full workflow configuration.
For other deployment platforms:
- Set
SECRET_KEY_BASE(generate withmix phx.gen.secret) - Set
DATABASE_URLfor your PostgreSQL instance - Set
PHX_HOSTto your domain - Configure SSL certificates if needed
See config/runtime.exs for production configuration details.
- BitcoinsvCli (
lib/bitcoinsv_cli.ex) - Bitcoin SV RPC client wrapper - Bitblocks.Sync (
lib/bitblocks/sync.ex) - Blockchain synchronization logic - Bitblocks.Chain (
lib/bitblocks/chain.ex) - Data context for blocks and transactions - BitblocksWeb - Phoenix web interface with LiveView
For detailed architecture documentation, see CLAUDE.md.
We welcome contributions! Please see CONTRIBUTING.md for details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with: