Quickstart Guide
This guide will walk you through setting up a complete blockchain in just a few minutes. You’ll initialize a chain, create accounts, deploy a smart contract, and produce blocks.Make sure you’ve completed the Installation guide before proceeding.
Step-by-Step Tutorial
Initialize a Blockchain
Create a new blockchain with one authority validator:You’ll see output like:This creates:
If you need to reset the chain later, add the
--force flag:- Genesis block (block #0)
- Authority keypair saved to
data/keys/authority_0.json - Configuration file at
data/config.json - Persistent blockchain database in
data/
Create User Accounts
Generate keypairs for two users, Alice and Bob:List all accounts:Each account gets:
- Ed25519 keypair for signing transactions
- Unique address derived from public key
- Saved to
data/keys/alice.jsonanddata/keys/bob.json
Fund Accounts
Only authorities can mint new tokens. Fund Alice so she can pay gas fees:Optionally fund Bob:
Replace
<ALICE_ADDRESS> with Alice’s actual address from step 2.Deploy a Smart Contract
Create a simple counter contract that increments a storage value.Create Deploy the contract:You’ll see:The assembly is compiled to bytecode and added to the mempool, but not yet on-chain.
counter.asm:Produce a Block
The deployment transaction is in the mempool. Produce a block to include it:Output:The contract is now deployed on-chain!
Call the Contract
Execute the counter contract to increment the value:Replace Call it again:The counter storage slot now holds value
<CONTRACT_ADDRESS> with the address from step 4.Produce another block to process the call:2 (incremented twice).Understanding What Happened
Let’s break down the blockchain flow:Transaction Lifecycle
Virtual Machine Execution
When the counter contract executes, the VM:- Loads bytecode from contract storage
- Initializes registers R0-R15 to zero
- Executes instructions one by one:
LOADI R0, 0: Load immediate value 0 into R0 (2 gas)SLOAD R1, R0: Read storage slot 0 into R1 (100 gas)LOADI R2, 1: Load immediate value 1 into R2 (2 gas)ADD R1, R1, R2: Add R1 + R2, store in R1 (2 gas)SSTORE R0, R1: Write R1 to storage slot 0 (5,000-20,000 gas)HALT: Stop execution (0 gas)
- Tracks gas consumed at each step
- Updates storage atomically if successful
Storage operations (
SLOAD, SSTORE) are intentionally expensive to reflect the cost of disk I/O.Gas Costs in Action
The counter contract execution costs approximately:--gas-limit 80000 — plenty of headroom for the contract.
Common CLI Commands
Here’s a quick reference of the most useful commands:| Command | Description | Example |
|---|---|---|
init | Initialize blockchain | minichain init --authorities 2 |
account new | Generate keypair | minichain account new --name alice |
account mint | Mint tokens (authority) | minichain account mint --from authority_0 --to 0xABC... --amount 50000 |
account balance | Check balance | minichain account balance 0xABC... |
account info | Account details | minichain account info 0xABC... |
account list | List all keypairs | minichain account list |
tx send | Transfer tokens | minichain tx send --from alice --to bob --amount 100 |
deploy | Deploy contract | minichain deploy --from alice --source contract.asm --gas-limit 80000 |
call | Call contract | minichain call --from alice --to 0xABC... --data 00 |
block produce | Produce new block | minichain block produce --authority authority_0 |
block list | List recent blocks | minichain block list --count 10 |
block info | Block details | minichain block info 5 |
Run
minichain --help or minichain <command> --help for detailed usage information.Complete Example Workflow
Here’s a full example showing token transfers and contract interactions:2 (incremented twice).
Next Steps
Now that you have a working blockchain:- Learn More: Dive into the Core Concepts to understand the architecture
- Write Contracts: Study the Assembly Language guide
- Explore the VM: Read about the Virtual Machine and gas metering
- Understand Consensus: Learn how Proof of Authority works
Core Concepts
Deep dive into blockchain primitives, transactions, and blocks
Assembly Language
Write smart contracts in Minichain’s assembly language
Virtual Machine
Understand the register-based VM and gas metering
CLI Reference
Complete command-line interface documentation