Skip to main content

Introduction

The Ubu-Block CLI is a command-line tool for managing blockchain operations, including initialization, validation, querying, and submitting election results. Built with Rust, it provides a fast and reliable interface for interacting with the Ubu-Block blockchain.

Installation

From Source

Clone the repository and build the CLI:
git clone <repo> ubu-block
cd ubu-block
cargo build --release
The compiled binary will be available at target/release/ubu-block.

Using Pre-built Binaries

  1. Download the latest binary from the releases page
  2. Make it executable: chmod +x ubu-block
  3. Move it to your PATH: sudo mv ubu-block /usr/local/bin/

Configuration

All CLI commands require a configuration file that specifies database locations. Use the -c or --config flag to specify the config file:
ubu-block --config config.toml <command>

Config File Format

The configuration file is in TOML format:
main_db = "sqlite://data/blockchain.db"
private_db = "sqlite://data/private.db"

Initial Setup

Before using the CLI, create the necessary directories and database files:
# Create data directory
mkdir data

# Create empty database files
cp crates/database/sql/empty.db data/blockchain.db
cp crates/database/sql/empty.db data/private.db

Available Commands

The Ubu-Block CLI provides the following commands:

init

Initialize a new blockchain with genesis block

submit

Submit polling station results to a submission node

query

Execute SQL queries on the blockchain data

validate

Verify blockchain integrity and validity

import

Import an existing SQLite blockchain database

Command Structure

All commands follow this general structure:
ubu-block --config <CONFIG_FILE> <COMMAND> [OPTIONS]

Global Options

--config
string
required
Path to the configuration file containing database connection strings
--version
flag
Display the CLI version
--help
flag
Display help information

Usage Examples

Initialize a blockchain

ubu-block --config config.toml init --source setup_constituencies.sql

Submit results

ubu-block --config config.toml submit http://localhost:3000 022113056303301 1 66

Query data

ubu-block --config config.toml query -q "SELECT * FROM results"

Validate blockchain

ubu-block --config config.toml validate

Getting Help

For help with any command:
# General help
ubu-block --help

# Command-specific help
ubu-block --config config.toml <command> --help

Next Steps

Initialize Blockchain

Learn how to create a new blockchain

Query Data

Explore querying blockchain data

Submit Results

Submit election results to nodes

Validate Chain

Verify blockchain integrity

Build docs developers (and LLMs) love