This is a monorepo containing two projects located in the explorer and indexer directories.
Indexer is a script written in TypeScript that runs every minute and fetches new blocks from bitcoind daemon, queries spaced for information about the fetched blocks and writes the relevant information to the database.
Make sure to install:
- Bitcoin Core: https://bitcoincore.org/en/download/
- Rust: https://www.rust-lang.org/tools/install
After installing Bitcoin Core, create a directory for Bitcoin testnet data:
mkdir $HOME/bitcoin-testnet
# Create a configuration file with RPC credentials
echo "rpcuser=test" > $HOME/bitcoin-testnet/bitcoin.conf
echo "rpcpassword=test" >> $HOME/bitcoin-testnet/bitcoin.conf
# Start Bitcoin Core in testnet mode
bitcoind -testnet -datadir=$HOME/bitcoin-testnetSpaces protocol is activated on Bitcoin testnet block 2865460 - wait for bitcoind to sync up to that block before proceeding.
spaced is a tiny layer on top of Bitcoin Core allowing you to interact with Spaces. To compile spaced, you need to install Rust and then
# Clone the repository
git clone https://github.com/spacesprotocol/spaced && cd spaced
# Build the release version
cargo build --release
# Install the binaries
cargo install --path node
# Ensure Cargo's bin directory is in your PATH
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcVerify you have spaced and space-cli installed:
spaced --version
space-cli --versionMake sure to run spaced with block indexing enabled:
spaced --chain test --block-index --bitcoin-rpc-user test --bitcoin-rpc-password testInstall dependencies:
cd indexer
npm installCreate an .env file:
cp .env.example .envIf needed, make changes to the .env file but if you fully followed this guide everything should work with the default values.
Same database is used by both the Explorer and the Indexer.
You can start the database using Docker or set up your own database.
To run it via Docker run the following command from the root directory, i.e. the directory where the docker-compose.yml is located:
docker compose up -dCreate the database schema:
cd indexer
npx drizzle-kit pushYou can start the indexer directly in the terminal or make it run in the background using pm2 and have it running even when you exit the terminal.
To start it in the terminal run:
npm run startTo run it via pm2 make sure to first install pm2:
npm i -g pm2Then build the app and run it:
npm run build
pm2 start dist/index.jsMake sure it's running:
pm2 statuscd explorer
npm installcp .env.example .envIf needed, make changes to the .env file but if you fully followed this guide everything should work with the default values.
You can start the explorer directly in the terminal or make it run in the background using pm2 and have it running even when you exit the terminal.
To start it in the terminal run:
npm run devThen you can open the browser at: http://localhost:5173/
To run it via pm2 make sure to first install pm2:
npm i -g pm2Then build the app and run it:
npm run build
pm2 start build/server.jsMake sure it's running:
pm2 statusYou can then open the explorer in a browser: http://localhost:3000