Build BBAChain from Source
This guide explains how to build and install BBAChain validator software from source code on your server.
Table of Contents
- Prerequisites
- Clone Repository
- Build from Source
- Install Validator
- Verify Installation
- Next Steps
- Troubleshooting
Prerequisites
Before building BBAChain from source, ensure you have:
- Server Setup: Your server is configured as described in the configuration guide
- User Account: You have access to the
bbachainuser account - System Updates: All system packages are up to date
- Build Tools: Required build dependencies installed (see below)
Required Build Dependencies
Install the required build dependencies:
sudo apt-get update
sudo apt-get install -y build-essential curl git pkg-config libssl-dev
Install Rust
BBAChain is written in Rust, so you need to install Rust and Cargo. BBAChain requires Cargo version 1.59.0.
Step 1: Install Rust
Install Rust using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
Step 2: Install Required Cargo Version
BBAChain requires Cargo version 1.59.0. Install this specific version:
rustup install 1.59.0
rustup default 1.59.0
Step 3: Verify Installation
Verify that Rust and Cargo are installed with the correct versions:
rustc --version
cargo --version
You should see output similar to:
rustc 1.59.0 (9d1b2106e 2022-02-23)
cargo 1.59.0 (49d8809dc 2022-02-10)
Important: BBAChain requires Cargo version 1.59.0. Using a different version may cause build errors or compatibility issues.
If you're building as the bbachain user, make sure to install Rust in that user's home directory.
Clone Repository
Step 1: Navigate to Home Directory
Switch to the bbachain user and navigate to the home directory:
sudo su - bbachain
cd ~
Step 2: Clone BBAChain Repository
Clone the BBAChain repository from GitHub:
git clone https://github.com/bbachain/bbachain.git
cd bbachain
This creates a bbachain directory in your home directory with the source code.
Step 3: Check Repository
Verify the repository was cloned successfully:
ls -la
git status
You should see the BBAChain source code files.
Build from Source
Step 1: Navigate to Repository
If you're not already in the repository directory:
cd ~/bbachain
Step 2: Checkout Latest Release (Optional)
For production use, it's recommended to checkout a specific release tag:
# List available tags
git tag -l
# Checkout latest stable release (replace with actual tag)
git checkout v1.0.0
For development or testing, you can use the main branch. For production, always use a stable release tag.
Step 3: Build Validator
Build the BBAChain validator from source:
cargo build --release
This command:
- Compiles the BBAChain validator software
- Creates optimized release binaries
- May take 30-60 minutes depending on your hardware
The --release flag creates optimized binaries suitable for production use. For faster builds during development, you can use cargo build without the --release flag.
Step 4: Monitor Build Progress
The build process will show progress. You can monitor it in real-time. The build will download dependencies and compile the code.
Expected Output:
Compiling bbachain v1.0.0 (/home/bbachain/bbachain)
...
Finished release [optimized] target(s) in 25m 30s
Install Validator
Step 1: Locate Built Binaries
After the build completes, the binaries will be in:
ls -lh ~/bbachain/target/release/
You should see binaries like:
bbachain-validator- The validator node softwarebbachain- CLI toolsbbachain-keygen- Keypair generation tool
Step 2: Install Binaries
Install the binaries to a system-wide location:
# Create installation directory
sudo mkdir -p /usr/local/bin
# Copy binaries
sudo cp ~/bbachain/target/release/bbachain-validator /usr/local/bin/
sudo cp ~/bbachain/target/release/bbachain /usr/local/bin/
sudo cp ~/bbachain/target/release/bbachain-keygen /usr/local/bin/
# Set permissions
sudo chmod +x /usr/local/bin/bbachain-validator
sudo chmod +x /usr/local/bin/bbachain
sudo chmod +x /usr/local/bin/bbachain-keygen
Step 3: Verify PATH
Ensure /usr/local/bin is in your PATH:
echo $PATH | grep /usr/local/bin
If not, add it to your shell profile:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Verify Installation
Step 1: Check Validator Version
Verify the validator software is installed correctly:
bbachain-validator --version
You should see output similar to:
bbachain-validator 1.0.0
Step 2: Check CLI Version
Verify the CLI tools are installed:
bbachain --version
Expected output:
bbachain-cli 1.0.0
Step 3: Check Keygen Version
Verify the keygen tool is installed:
bbachain-keygen --version
Expected output:
bbachain-keygen 1.0.0
Step 4: Test CLI Commands
Test that the CLI is working correctly:
bbachain --help
This should display the available commands and options.
Success! If all version commands work correctly, you have successfully built and installed BBAChain from source.
Alternative: Install from Pre-built Binaries
If you prefer not to build from source, you can download pre-built binaries:
# Download latest release (example)
wget https://github.com/bbachain/bbachain/releases/download/v1.0.0/bbachain-validator-linux-x86_64
chmod +x bbachain-validator-linux-x86_64
sudo mv bbachain-validator-linux-x86_64 /usr/local/bin/bbachain-validator
Check the GitHub releases page for the latest pre-built binaries.
Next Steps
Now that you have successfully built and installed BBAChain (including CLI and keygen tools):
- Generate keypairs: Create the required keypairs for your validator
- Start validator: Begin running your validator node (see next guide)
- Monitor validator: Set up monitoring and health checks for your validator node
Troubleshooting
Build Errors
If you encounter build errors:
-
Check Cargo Version:
cargo --versionEnsure you have Cargo version 1.59.0 (required for BBAChain).
-
Install Correct Version:
If you have a different version, install the required version:
rustup install 1.59.0
rustup default 1.59.0 -
Verify Version:
cargo --versionYou should see:
cargo 1.59.0 -
Clean Build:
cd ~/bbachain
cargo clean
cargo build --release
Missing Dependencies
If you get dependency errors:
sudo apt-get update
sudo apt-get install -y build-essential curl git pkg-config libssl-dev
Permission Issues
If you encounter permission issues:
- Ensure you're using the
bbachainuser for building - Use
sudoonly when installing to system directories - Check file permissions on binaries
Build Takes Too Long
If the build is taking too long:
- Ensure you have sufficient CPU cores (build uses parallel compilation)
- Check available RAM (build requires significant memory)
- Consider using pre-built binaries for faster setup
Version Command Not Found
If bbachain --version doesn't work:
-
Check Installation:
ls -la /usr/local/bin/bbachain* -
Check PATH:
echo $PATH
which bbachain -
Reinstall:
sudo cp ~/bbachain/target/release/bbachain /usr/local/bin/
sudo chmod +x /usr/local/bin/bbachain
Related Topics
- Learn about validator requirements
- Configure your validator node
- Generate keypairs for your validator
- Install CLI via npm (alternative method)
- Understand BBAChain networks
Next Steps: After verifying the installation, proceed to generate keypairs for your validator.