Overview
Initializing a blockchain creates the genesis block and sets up the necessary database structure. This process establishes the foundation for your election results blockchain.Prerequisites
Before initializing, ensure you have:- Ubu-Block CLI installed
- A configuration file (typically
config.toml) - An initialization SQL file with your regional setup
Setup Database Files
Initialize the Blockchain
Prepare initialization SQL
Create an SQL file that defines your regional structure (constituencies, wards, stations, etc.). Example:
setup_constituencies.sqlThis file should include:- Counties and constituencies
- Wards and polling stations
- Candidates and parties
Run initialization command
Execute the init command with your configuration and setup file:The
--source parameter specifies the path to your initialization SQL file that sets up the regional data structure.What Happens During Initialization
The initialization process performs several critical operations:- Database Setup: Creates the necessary tables in both main and private databases
- Key Generation: Generates an Ed25519 keypair for signing blocks
- Genesis Block: Creates the first block (genesis block) with:
- Your regional data structure hash
- Initial creator public key
- Height 0
- Key Storage: Stores the public key in the main database and private key securely in the private database
The genesis block is special—it has no previous block hash and establishes the initial state of your blockchain.
Configuration File
Yourconfig.toml should specify database paths:
Next Steps
After initialization:- Submit election results to add blocks
- Query the blockchain to view data
- Validate integrity to ensure data consistency
- Connect to peers to join the network