đ„ Developer Setup - Pre-requisites and Installation
This guide assists you in setting up the Teranode project on your machine. The below assumes you are running a recent version of Mac OS.
Index
- Install Go
- Set Go Environment Variables
- Python and Dependencies
- Clone the Project and Install Dependencies
- Run the Node
- Troubleshooting
1. Install Go
Download and install the latest version of Go. As of June 2025, it's 1.24.3
.
Test Installation: Open a new terminal and execute:
go version
go1.24.3
or above.
2. Set Go Environment Variables
Add these lines to .zprofile
or .bash_profile
, depending on which one your development machine uses:
export PATH="$PATH:$(go env GOPATH)/bin"
export GOPATH="$(go env GOPATH)"
export GOBIN="$(go env GOPATH)/bin"
Test Configuration: Open a new terminal and execute:
echo $GOPATH
echo $GOBIN
Both should display paths related to Go.
3. Python and Dependencies
3.1 Install Python (via Homebrew)
brew install python
By default, Homebrew will install Python 3.x and create symlinks like python3
and pip3
. You can optionally create a symlink for python
and pip
if you want shorter commands (but check if they already exist first):
ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python # might already exist
ln -s /opt/homebrew/bin/pip3 /opt/homebrew/bin/pip # might already exist
3.2 (Recommended) Use a Python Virtual Environment to install PyYAML
Because of PEP 668 and Homebrewâs âexternally-managed-environmentâ setup, you canât do pip install ...
directly into the system-wide Python.
Instead, create and activate a virtual environment:
python3 -m venv ~/my_python_env # choose any path you like
source ~/my_python_env/bin/activate
(my_python_env)
as a prefix.
3.3 Install Dependencies Within the Virtual Environment
Once your virtual environment is active, you can safely use pip
to install packages without system conflicts:
python -m pip install --upgrade pip
pip install PyYAML
3.4 Verify Installation
python -c "import yaml; print(yaml.__version__)"
6.0.2
or similar).
Alternative: Use pipx
(for CLI tools) - NOT recommended for Teranode Development
If you need PyYAML as part of a standalone command-line tool, you could use pipx instead:
brew install pipx
pipx install PyYAML
4. Clone the Project and Install Dependencies
Clone the project:
git clone git@github.com:bsv-blockchain/teranode.git
Install all dependencies: Execute:
cd teranode
# This will install all required dependencies (protobuf, golangci-lint, etc.)
make install
Note: If you receive an error
ModuleNotFoundError: No module named âyamlâ
error, refer to this issue for a potential fix. Example:PYTHONPATH=$HOME/Library/Python/3.9/lib/python/site-packages make install #Make sure the path is correct for your own python version
5. Configure Settings
Teranode uses two configuration files:
settings.conf
- Contains sensible defaults for all environments. You should NOT modify this file as part of the scope of this guide.settings_local.conf
- Contains developer-specific and deployment-specific settings
5.1 Introducing developer-specific settings in settings_local.conf
-
In your project directory, create a file
settings_local.conf
. This file is used for your personal development settings, and it's not tracked in source control. -
Introduce any settings override in
settings_local.conf
that you might require for your development. Use thesettings.conf
as a reference for common settings and their default values. -
The settings you are adding will use a prefix (settings context) that identifies your context. By default, your settings context should be
dev.
. You can further refine this by using a more specific prefix, such asdev.john
ordev.me
. However, it is recommended to use the default prefixdev.
, and only refine it in very specific cases.
In order for your node to read your custom lines, you set SETTINGS_CONTEXT
to match the prefix you used (i.e., dev
).
In zsh, open ~/.zprofile
(or ~/.zshrc
). In bash, open ~/.bash_profile
(or ~/.bashrc
).
Add:
export SETTINGS_CONTEXT=dev
dev.john
, you would set SETTINGS_CONTEXT=dev.john
)
After editing, reload your shell config:
source ~/.zprofile
5.3 Verify
-
Echo the environment variable to ensure itâs set correctly:
Should printecho $SETTINGS_CONTEXT
dev
. -
Run or restart your node. Check logs or console output to confirm itâs picking up the lines with
dev
.
6. Prerequisites for Running the Node
6.1 Install Docker for Mac
Kafka runs in Docker containers, so you'll need to install Docker for Mac:
- Download Docker Desktop for Mac from Docker Hub
- Double-click the downloaded
.dmg
file and drag the Docker app to your Applications folder - Launch Docker Desktop from your Applications folder
- When prompted, authorize Docker with your system password
- Wait for Docker to start (the whale icon in the status bar will stop animating when Docker is ready)
Verify Docker installation:
docker --version
6.2 Start Kafka and PostgreSQL
Once Docker is installed and running, start Kafka and PostgreSQL with:
# Start Kafka in Docker
./scripts/kafka.sh
# Start PostgreSQL in Docker
./scripts/postgres.sh
These scripts will set up Docker containers with the required services configured correctly for Teranode.
Note: If you configure your settings to use Aerospike for UTXO storage, you'll also need to run the Aerospike script:
# Start Aerospike in Docker ./scripts/aerospike.sh
7. Run the Node
You can run the entire node with the following command:
SETTINGS_CONTEXT=dev.[YOUR_CONTEXT] go run .
If no errors are seen, you have successfully installed the project and are ready to start working on the project or running the node.
Note that the node is initialized in IDLE mode by default. You'll need to transition it to RUNNING mode to start processing transactions.
7.1. Executing the Teranode-CLI as a Developer
The Teranode-CLI allows you to interact with Teranode services. You can use it to transition the node to different states, query its current state, and perform various maintenance operations. For a comprehensive guide on using the Teranode-CLI as a developer, see the Developer's Guide to Teranode-CLI.
Building the Teranode-CLI
Build the Teranode-CLI tool with:
go build -o teranode-cli ./cmd/teranodecli
Executing Commands
Once built, you can run commands directly:
# Get current FSM state
SETTINGS_CONTEXT=dev.[YOUR_CONTEXT] ./teranode-cli getfsmstate
# Set FSM state to RUNNING
SETTINGS_CONTEXT=dev.[YOUR_CONTEXT] ./teranode-cli setfsmstate --fsmstate running
Available Commands
The Teranode-CLI provides several commands:
Command | Description |
---|---|
getfsmstate |
Get the current FSM State |
setfsmstate |
Set the FSM State (with --fsmstate flag) |
settings |
View system configuration |
aerospikereader |
Read transaction data from Aerospike |
filereader |
Read and process files |
seeder |
Seed initial blockchain data |
bitcointoutxoset |
Convert Bitcoin data to UTXO set |
utxopersister |
Manage UTXO persistence |
export-blocks |
Export blockchain to CSV |
import-blocks |
Import blockchain from CSV |
checkblocktemplate |
Check block template |
Getting Help
For general help and a list of available commands:
# General help
./teranode-cli
# Command-specific help
./teranode-cli setfsmstate --help
The CLI will use your development settings as specified by your SETTINGS_CONTEXT
environment variable.
Transitioning the Node to RUNNING Mode
To transition the node from IDLE to RUNNING mode, use:
# Get current FSM state
SETTINGS_CONTEXT=dev ./teranode-cli getfsmstate
# Set FSM state to RUNNING
SETTINGS_CONTEXT=dev ./teranode-cli setfsmstate --fsmstate running
After executing these commands, your log should show a successful transition:
[Blockchain Client] FSM successfully transitioned from IDLE to state:RUNNING
8. Troubleshooting
8.1. Dependency errors and conflicts
Should you have errors with dependencies, try running the following commands:
go clean -cache
go clean -modcache
rm go.sum
go mod tidy
go mod download
This will effectively reset your cache and re-download all dependencies.