This guide will walk you through the process of setting up a genesis for your chain. Follow the steps below to initialize your chain, add a genesis account, and start the chain.
For this guide you need to have a chain directory where you have created and built your chain.
If you don't have a chain directory yet, you can initialize a simple ignite chain by following this tutorial
:::tip This guide will use the simple ignite chain created in linked guide. Make sure to update any relevant variables to match your chain. :::
First, set the necessary variables for your chain in the terminal, here is an example:
VALIDATOR_NAME=validator1
CHAIN_ID=gm
KEY_NAME=chain-key
CHAINFLAG="--chain-id ${CHAIN_ID}"
TOKEN_AMOUNT="10000000000000000000000000stake"
STAKING_AMOUNT="1000000000stake"Ensure that .gm folder is present at /Users/you/.gm (if not, follow a Guide to set it up) and run the following command to (re)generate an entrypoint binary out of the code:
make installOnce completed, run the following command to ensure that the /Users/you/.gm directory is present:
ignite rollkit initThis (re)creates an gmd binary that will be used for the rest of the tutorials to run all the operations on the chain.
Reset any existing chain data:
gmd comet unsafe-reset-allReset any existing genesis data:
rm -rf $HOME/.$CHAIN_ID/config/gentx
rm $HOME/.$CHAIN_ID/config/genesis.jsonInitialize the validator with the chain ID you set:
gmd init $VALIDATOR_NAME --chain-id $CHAIN_IDAdd a key to the keyring-backend:
gmd keys add $KEY_NAME --keyring-backend testAdd a genesis account with the specified token amount:
gmd genesis add-genesis-account $KEY_NAME $TOKEN_AMOUNT --keyring-backend testSet the staking amount in the genesis transaction:
gmd genesis gentx $KEY_NAME $STAKING_AMOUNT --chain-id $CHAIN_ID --keyring-backend testCollect the genesis transactions:
gmd genesis collect-gentxsCopy the centralized sequencer address into genesis.json:
ADDRESS=$(jq -r '.address' ~/.$CHAIN_ID/config/priv_validator_key.json)
PUB_KEY=$(jq -r '.pub_key' ~/.$CHAIN_ID/config/priv_validator_key.json)
jq --argjson pubKey "$PUB_KEY" '.consensus["validators"]=[{"address": "'$ADDRESS'", "pub_key": $pubKey, "power": "1000", "name": "Rollkit Sequencer"}]' ~/.$CHAIN_ID/config/genesis.json > temp.json && mv temp.json ~/.$CHAIN_ID/config/genesis.jsonFinally, start the chain with your start command.
For example, start the simple ignite chain with the following command:
gmd start --rollkit.node.aggregator --chain_id $CHAIN_IDBy following these steps, you will set up the genesis for your chain, initialize the validator, add a genesis account, and started the chain. This guide provides a basic framework for configuring and starting your chain using the gm-world binary. Make sure you initialized your chain correctly, and use the gmd command for all operations.