Quick Start Guide: zigchaind
zigchaind is the ZIGChain CLI. It is a command line tool that allows you to interact with the ZIGChain network. It is the primary tool for managing your ZIGChain node, wallet, and other related tasks on the ZIGChain network.
Quick Start on a Local Machine
The following steps guide you through installing ZIGChain on an x86 Linux machine or a Mac with an Apple Silicon Processor.
You will need to have Go and WASM library installed before setting up the ZIGChain CLI.
Install Go
Check if Go is installed:
go version
If you have a lower version than 1.23.6 (at the time of writing), uninstall the old version to upgrade to the needed version.
- Linux
- Mac
Uninstall old Go version: First, remove the golang-go package and its dependencies:
sudo apt-get remove --auto-remove golang-go
Then purge all configuration and data:
sudo apt-get purge golang-go
sudo apt-get purge --auto-remove golang-go
Finally, verify the uninstallation:
go version
Uninstall old Go version: First, check where Go is installed:
which go
Then remove all Go files:
sudo rm -rf /usr/local/go
sudo rm /etc/paths.d/go
Using apt install would install an outdated version of Go (e.g., 1.18 at the time of writing). Instead, we will install the latest version from the official website.
Check Your CPU Architecture
Before downloading the Go binary, check your CPU architecture to ensure you download the correct version.
- Linux
- Mac
Check your CPU architecture:
lscpu | grep -e "Model name" -e "Architecture"
You should see something like:
Architecture: x86_64
Model name: Intel(R) Xeon(R) CPU @ 2.30GHz
Check your CPU architecture:
uname -m
You should see something like:
arm64
Download the Correct Go Binary
Based on your architecture, download the appropriate Go binary from the Go official website.
- Linux
- Mac
- x86_64/amd64 architecture: use linux-amd64 (default below)
- arm64 architecture: use linux-arm64 instead
cd /tmp/
wget https://go.dev/dl/go1.23.6.linux-amd64.tar.gz
sudo tar -zxvf go1.23.6.linux-amd64.tar.gz -C /usr/local/
- Apple Silicon (M1/M2): use darwin-arm64 (default below)
- Intel: use darwin-amd64 instead
cd /tmp/
curl -O https://go.dev/dl/go1.23.6.darwin-arm64.tar.gz
sudo tar -zxvf go1.23.6.darwin-arm64.tar.gz -C /usr/local/
Lastly (if go was not previously installed) you will need to add the following to your .bashrc or .zshrc file:
- zsh
- bash
echo 'export GOROOT=/usr/local/go' >> ~/.zshrc
echo 'export GOPATH=$HOME/go' >> ~/.zshrc
echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.zshrc
Source the file to apply the changes (or exit and log back in):
source ~/.zshrc
echo 'export GOROOT=/usr/local/go' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc
Source the file to apply the changes (or exit and log back in):
source ~/.bashrc
Verify if go is installed by running the following command:
go version
Get Cosmwasm Library
Get the Cosmwasm Library:
- Linux
- Mac
sudo wget -O /usr/lib/libwasmvm.x86_64.so https://github.com/CosmWasm/wasmvm/releases/download/v2.2.3/libwasmvm.x86_64.so
sudo curl -L -o /usr/local/lib/libwasmvm.dylib https://github.com/CosmWasm/wasmvm/releases/download/v2.2.3/libwasmvm.dylib
sudo chmod +x /usr/local/lib/libwasmvm.dylib
Install ZIGChain Binary
Install the ZIGChain CLI by downloading the latest pre-built binaries. The tar file also contains the script to launch and generate the genesis.
Check the latest binaries here: https://github.com/ZIGChain/networks
- Linux
- Mac
cd /tmp/
LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/ZIGChain/networks/refs/heads/main/zig-test-1/version.txt)
wget "https://raw.githubusercontent.com/ZIGChain/networks/refs/heads/main/zig-test-1/binaries/zigchaind-${LATEST_VERSION}-linux-amd64.tar.gz"
tar -zxvf "zigchaind-${LATEST_VERSION}-linux-amd64.tar.gz"
mkdir -p $HOME/go/bin
mv ./zigchaind $HOME/go/bin/zigchaind
cd /tmp/
LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/ZIGChain/networks/refs/heads/main/zig-test-1/version.txt)
curl -O "https://raw.githubusercontent.com/ZIGChain/networks/refs/heads/main/zig-test-1/binaries/zigchaind-${LATEST_VERSION}-darwin-arm64.tar.gz"
tar -zxvf "zigchaind-${LATEST_VERSION}-darwin-arm64.tar.gz"
mkdir -p $HOME/go/bin
mv ./zigchaind $HOME/go/bin/zigchaind
Check that it works by running the following command:
zigchaind --help
If you have problem with permissions, ensure the folder has the correct permissions.
With the genesis you have also downloaded a script that setups genesis and some initial test accounts
First, check if installed and if not, install jq:
- Linux
- Mac
Check if jq is installed:
which jq
Install jq (if not installed):
sudo apt install jq
Check if jq is installed:
which jq
Install jq (if not installed):
brew install jq
Execute the script with:
cd /tmp/
chmod +x ./zigchain_local_setup.sh
./zigchain_local_setup.sh
Start the blockchain with:
zigchaind start
Test accounts created
On genesis, the following accounts are created for testing purposes with the following mnemonics
VAL_KEY="valuser1"
VAL_MNEMONIC="debate pottery prize tag lottery lounge protect fancy keep orbit person stage ten possible expect spend utility estate hope people attack input oval bird"
ZUSER1_KEY="zuser1"
ZUSER1_MNEMONIC="horse elite dog fix slide moon rely wife convince pear visa woman make rent giraffe under lawn impulse visit improve together above mixed what"
ZUSER2_KEY="zuser2"
ZUSER2_MNEMONIC="motion toddler sad surge present spot destroy clarify lyrics drastic cactus rhythm cupboard govern space soft fan accuse source spend artwork state smart motor"
ZUSER3_KEY="zuser3"
ZUSER3_MNEMONIC="design coral crawl aerobic airport engine spice impulse hobby limit twelve budget praise dog usage comic rain icon miss custom worth upper blade path"
ZUSER4_KEY="zuser4"
ZUSER4_MNEMONIC="blue define teach split satisfy mention food loop economy gravity lobster keep card milk smile unable barely attack shoot bulk vapor hybrid board drift"
ZUSER5_KEY="zuser5"
ZUSER5_MNEMONIC="net impact drift popular debris coast wrong iron amazing patient poet forward occur any private chunk tonight final clump general video bracket abstract fade"
Examples to interact with the zigchaind:
Example: Send and broadcast a transaction
In this example, we will:
- Send a transaction from one account to another using the ZIGChain CLI.
- Broadcast the transaction.
Step 1️⃣: Get the initial balance of the accounts
zigchaind query bank balances zuser1 --chain-id zigchain-1
zigchaind query bank balances zuser5 --chain-id zigchain-1
Step 2️⃣: Send a transaction
zigchaind tx bank send $(zigchaind keys show zuser1 -a) $(zigchaind keys show zuser5 -a) 100uzig --from zuser1 --gas auto --gas-adjustment 1.3 --gas-prices 0.00025uzig --chain-id zigchain-1
Get the transaction id (txhash) from the response
Step 3️⃣: Check the transaction
TX_ID=REPLACE_ME
zigchaind query tx $TX_ID --chain-id zigchain-1
Check the information under the "raw_log" field. If empty, means that everything went well.
Step 4️⃣: Verify that the sender's balance has decreased by the transferred amount plus gas fees
zigchaind query bank balances zuser1 --chain-id zigchain-1
zigchaind query bank balances zuser5 --chain-id zigchain-1