Launching Your Own Antelope Blockchain Chapter 2: Enacting the Laws and Economy

Will Hill
13 min readFeb 25, 2024

--

As dawn breaks over our burgeoning digital kingdom, our quest delves deeper into the mystical arts of governance and the alchemy of economics. With the guardian spirits (Nodeos) keeping a vigilant watch, it’s time to weave the magics that will govern the lands and mint the gold that will fuel our dreams.

Ensuring the Sanctity of Your Realm

With your arcane wallet at the ready and the mystical keys securely in your possession, you stand at the threshold of destiny. These keys are not mere tools; they are the scepters of command, granting you the authority to decree laws and mint the currency that will sustain your realm. Guard these scepters as jealously as you would your crown, for within them lies the power to sculpt worlds or beckon chaos.

Act 7: Unleashing the Protocol Features

In the hallowed chambers of your castle, you prepare a potent script, a magic scroll that, once unfurled, will unlock ancient magics dormant within your realm. Whisper to the spirits with the following incantation to reveal the arcane symbols needed to awaken these powers:

# This command retrieves a list of all supported protocol features from the blockchain.
# Protocol features are specific functionalities or improvements that can be activated on the blockchain.
cleos -u http://localhost:8888/ get supported_protocol_features
# Digests can be found here for reference
http://eos.api.eosnation.io/

Remember to activate the PREACTIVATE_FEATURE before proceeding with eosio.boot

# This command initiates a POST request to the local nodeos endpoint, instructing it to activate a specific protocol feature on the blockchain. 
# The feature to be activated is identified by its digest "0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd",
# which is typically the PREACTIVATE_FEATURE required for enabling the use of new consensus protocol features before deploying the eosio.system contract.
curl -X POST http://127.0.0.1:8888/v1/producer/schedule_protocol_feature_activations \
-d '{"protocol_features_to_activate": ["0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd"]}'

Act 8: Conjuring the Contracts of Power

Now, to the very heart of our saga. With the ether stabilized and the guardian spirits at your side, you must invoke the Contracts of Power. These are no mere documents but the very edicts by which your kingdom shall either thrive or falter.

Preparation of the Sacred Repository

First, we journey to the ancient, ever-updating repository of AntelopeIO, where the Contracts of Power are safeguarded. Clone this repository to access the latest system contracts, the blueprints of governance for any realm.

# Clone the 'reference-contracts' repository to access the latest system contracts.
git clone https://github.com/AntelopeIO/reference-contracts.git /tmp

The Ritual of Compilation

Armed with the Contract Development Toolkit (CDT), we shall transmute these sacred texts. This mystical process transforms the raw ether of code into a form that the blockchain can comprehend and execute.

# Update the system's package list and install build-essential, cmake, and wget packages. These tools are necessary for compiling software from source, including blockchain smart contracts and other dependencies.
sudo apt update && sudo apt install build-essential cmake wget -y


# Download the AntelopeIO Contract Development Toolkit (CDT) version 4.0.1. The CDT provides the necessary tools and libraries for developing and compiling smart contracts for Antelope-based blockchains. This version is suitable for 64-bit systems and supports the latest features and optimizations for smart contract development.
wget https://github.com/AntelopeIO/cdt/releases/download/v4.0.1/cdt_4.0.1_amd64.deb

# Install the downloaded CDT package. This step installs the EOSIO CDT, making it available system-wide and enabling developers to compile and deploy smart contracts on Antelope-based blockchains.
sudo apt install ./cdt_4.0.1_amd64.deb -y

#verify the install
cdt-cpp --version

# Navigate to the cloned 'reference-contracts' directory and execute the build script. This script compiles the smart contracts contained within the repository, preparing them for deployment on the blockchain. It utilizes the CDT installed earlier to compile the contracts into WebAssembly (WASM) format, which is required for execution on Antelope-based blockchains.
cd /tmp/reference-contracts && ./build.sh

Deployment of the Laws

eosio.bios: The foundational scroll, imbuing our realm with the ability to set permissions and enabling the deployment of further potent contracts.

eosio.token: Through this powerful contract, we conjure the currency of our realm, the lifeblood of our economy and the sustenance of our people.

eosio.system: At the heart of our governance, this contract weaves the fabric of resource management, account creation, and the sacred rites of voting, binding our realm in unity and purpose.

eosio.msig: For decisions that require the consensus of the wise, this contract enables the creation and approval of multi-signatory proposals, ensuring harmony and balance.

Deploying the eosio.boot Scroll

Prepare to deploy the eosio.boot, a crucial step in awakening the full potential of our blockchain:

# Navigate to the directory where the compiled contracts are located, specifically the 'eosio.bios' contract within the 'reference-contracts' project. This directory contains the contract files needed to deploy 'eosio.bios' to the blockchain.
cd /tmp/reference-contracts/build/contracts

# Open an existing wallet using 'cleos'. This command prepares the wallet for further interactions, such as key management and signing transactions. If the wallet is already open, this command has no effect, but it's necessary to run it before performing operations that require wallet access if the wallet has been closed or if the 'keosd' wallet daemon has been restarted. It ensures the wallet is unlocked and ready to use, but note that opening the wallet does not automatically unlock it; you will need to use 'cleos wallet unlock' with your wallet's password for that.
cleos wallet open

# Unlock an already opened wallet using 'cleos'. This command makes the private keys stored within the wallet accessible for signing transactions or performing other operations requiring authentication. Upon execution, you will be prompted to enter the wallet's password. This step is critical for security, ensuring that only authorized users can access and use the private keys. Remember, the wallet must be opened before it can be unlocked. If the wallet is not open, use 'cleos wallet open' first. This command is essential for any blockchain operation that requires transaction signing or key management.
cleos wallet unlock

# Deploy the 'eosio.bios' contract to the 'eosio' system account on the blockchain using 'cleos'. The 'eosio.bios' contract is a basic system contract that provides essential functions for blockchain operations, such as defining accounts and permissions. This step is crucial in the initial setup of the blockchain, as it prepares the system for further configuration and deployment of other system contracts. The '-p eosio@active' flag specifies that the action is authorized by the 'active' permission of the 'eosio' account, which is typically controlled by the private key held by the blockchain's administrators. Deploying this contract is one of the first steps in configuring a new Antelope blockchain environment.
cleos set contract eosio ./eosio.boot -p eosio@active

Crafting the Scroll of Activation

In a moment of quiet before the storm, we craft a scroll named activate_features.sh, a potent artifact that, when invoked, will awaken dormant features within our land, imbuing it with unseen powers and capabilities:

# This command changes the current directory to 'antelope-blockchain' located in the home directory.
# It navigates the terminal's context to the specified folder where Antelope blockchain-related files or configurations might reside.
cd /tmp
# This command opens the 'activate_features.sh' script file in the Nano text editor for editing or review.
# If the file does not exist, Nano will create a new file with this name.
nano activate_features.sh

Inscribe upon this scroll the spells to activate the features, each a key turning in the lock of destiny:

#!/bin/bash

# EOSIO account executing the commands
ACCOUNT="eosio@active"
# cleos command with node and wallet setup
CLEOS="cleos --url http://localhost:8888"
# List of feature digests to activate
declare -a features=(
"c3a6138c5061cf291310887c0b5c71fcaffeab90d5deb50d3b9e687cead45071" # ACTION_RETURN_VALUE
"d528b9f6e9693f45ed277af93474fd473ce7d831dae2180cca35d907bd10cb40" # CONFIGURABLE_WASM_LIMITS2
"5443fcf88330c586bc0e5f3dee10e7f63c76c00249c87fe4fbf7f38c082006b4" # BLOCKCHAIN_PARAMETERS
"f0af56d2c5a48d60a4a5b5c903edfb7db3a736a94ed589d0b797df33ff9d3e1d" # GET_SENDER
"2652f5f96006294109b3dd0bbde63693f55324af452b799ee137a81a905eed25" # FORWARD_SETCODE
"8ba52fe7a3956c5cd3a656a3174b931d3bb2abb45578befc59f283ecd816a405" # ONLY_BILL_FIRST_AUTHORIZER
"ad9e3d8f650687709fd68f4b90b41f7d825a365b02c23a636cef88ac2ac00c43" # RESTRICT_ACTION_TO_SELF
"68dcaa34c0517d19666e6b33add67351d8c5f69e999ca1e37931bc410a297428" # DISALLOW_EMPTY_PRODUCER_SCHEDULE
"e0fb64b1085cc5538970158d05a009c24e276fb94e1a0bf6a528b48fbc4ff526" # FIX_LINKAUTH_RESTRICTION
"ef43112c6543b88db2283a2e077278c315ae2c84719a8b25f25cc88565fbea99" # REPLACE_DEFERRED
"4a90c00d55454dc5b059055ca213579c6ea856967712a56017487886a4d4cc0f" # NO_DUPLICATE_DEFERRED_ID
"1a99a59d87e06e09ec5b028a9cbb7749b4a5ad8819004365d02dc4379a8b7241" # ONLY_LINK_TO_EXISTING_PERMISSION
"4e7bf348da00a945489b2a681749eb56f5de00b900014e137ddae39f48f69d67" # RAM_RESTRICTIONS
"4fca8bd82bbd181e714e283f83e1b45d95ca5af40fb89ad3977b653c448f78c2" # WEBAUTHN_KEY
"299dcb6af692324b899b39f16d5a530a33062804e41f09dc97e9f156b4476707" # WTMSIG_BLOCK_SIGNATURES
"bcd2a26394b36614fd4894241d3c451ab0f6fd110958c3423073621a70826e99" # GET_CODE_HASH
"35c2186cc36f7bb4aeaf4487b36e57039ccf45a9136aa856a5d569ecca55ef2b" # GET_BLOCK_NUM
"6bcb40a24e49c26d0a60513b6aeb8551d264e4717f306b81a37a5afb3b47cedc" # CRYPTO_PRIMITIVES
"63320dd4a58212e4d32d1f58926b73ca33a247326c2a5e9fd39268d2384e011a" # BLS_PRIMITIVES2
"fce57d2331667353a0eac6b4209b67b843a7262a848af0a49a6e2fa9f6584eb4" # DISABLE_DEFERRED_TRXS_STAGE_1
"09e86cb0accf8d81c9e85d34bea4b925ae936626d00c984e4691186891f5bc16" # DISABLE_DEFERRED_TRXS_STAGE_2
)
# Activate each feature
for digest in "${features[@]}"
do
echo "Activating feature: $digest"
$CLEOS push action eosio activate "{\"feature_digest\":\"$digest\"}" -p $ACCOUNT
# Wait a bit between activations if needed
sleep 1
done
echo "All specified protocol features have been activated."

To make this scroll a conduit of your will, a touch of the old magic is required:

# This command changes the permissions of the 'activate_features.sh' script to make it executable.
# It grants execution rights to the user, allowing the script to be run as a program.
chmod +x activate_features.sh

With a flick of your wrist, you command the power of the script, watching as the dormant features weave into the very fabric of your realm:

# This command executes the 'activate_features.sh' script from the current directory.
# It runs the script that is designed to activate certain features on the Antelope blockchain.
./activate_features.sh

Bestowing the Latest Version of eosio.system

As the final act in our ritual, we deploy the eosio.system contract, the cornerstone of our governance and the keeper of order within our realm:


# Open an existing wallet using 'cleos'. This command prepares the wallet for further interactions, such as key management and signing transactions. If the wallet is already open, this command has no effect, but it's necessary to run it before performing operations that require wallet access if the wallet has been closed or if the 'keosd' wallet daemon has been restarted. It ensures the wallet is unlocked and ready to use, but note that opening the wallet does not automatically unlock it; you will need to use 'cleos wallet unlock' with your wallet's password for that.
cleos wallet open

# Unlock an already opened wallet using 'cleos'. This command makes the private keys stored within the wallet accessible for signing transactions or performing other operations requiring authentication. Upon execution, you will be prompted to enter the wallet's password. This step is critical for security, ensuring that only authorized users can access and use the private keys. Remember, the wallet must be opened before it can be unlocked. If the wallet is not open, use 'cleos wallet open' first. This command is essential for any blockchain operation that requires transaction signing or key management.
cleos wallet unlock

# Deploy the 'eosio.system' contract to the 'eosio' system account on the blockchain using 'cleos'. The 'eosio.bios' contract is a basic system contract that provides essential functions for blockchain operations, such as defining accounts and permissions. This step is crucial in the initial setup of the blockchain, as it prepares the system for further configuration and deployment of other system contracts. The '-p eosio@active' flag specifies that the action is authorized by the 'active' permission of the 'eosio' account, which is typically controlled by the private key held by the blockchain's administrators. Deploying this contract is one of the first steps in configuring a new Antelope blockchain environment.
cleos set contract eosio ./eosio.system -p eosio@active

# Deploy the 'eosio.token' contract to the 'eosio' token account on the blockchain using 'cleos'. The 'eosio.bios' contract is a basic system contract that provides essential functions for blockchain operations, such as defining accounts and permissions. This step is crucial in the initial setup of the blockchain, as it prepares the system for further configuration and deployment of other system contracts. The '-p eosio@active' flag specifies that the action is authorized by the 'active' permission of the 'eosio' account, which is typically controlled by the private key held by the blockchain's administrators. Deploying this contract is one of the first steps in configuring a new Antelope blockchain environment.
cleos set contract eosio.token /tmp/reference-contracts/build/contracts/eosio.token eosio.token.wasm eosio.token.abi -p eosio.token@active

Thus, with the laws deployed and the scrolls of power activated, our realm stands on the cusp of a new era. Governance structures solidify, economies flourish, and the people look towards a future bright with promise. Our tale of creation and command, of wisdom and power, continues to unfold.

Act 9: Summoning the System Guardians

In the twilight of our preparations, we embark on crafting the sacred system_accounts.sh scroll, a tome powerful enough to summon the system guardians into existence within our digital dominion.

# This command changes the current directory to 'antelope-blockchain' located in the home directory.
# It navigates the terminal's context to the specified folder where Antelope blockchain-related files or configurations might reside.
cd /tmp
# This command opens the 'activate_features.sh' script file in the Nano text editor for editing or review.
# If the file does not exist, Nano will create a new file with this name.
nano system_accounts.sh

Upon this scroll, we etch the following incantations, each a summoning spell for the guardians of our realm:

#!/bin/bash

# Define the initial account that has permissions to create other accounts
creator="eosio"
creator_private_key="5JPV237Vq8xSzpwZ1dhza4aYE1ogL7DbEqXnXMnHWiXA84kxa97"

# The URL of the node you're interacting with
node_url="http://localhost:8888"

# Define the list of new accounts to create
declare -a accounts=(
'eosio.bpay'
'eosio.msig'
'eosio.names'
'eosio.ram'
'eosio.ramfee'
'eosio.saving'
'eosio.stake'
'eosio.token'
'eosio.vpay'
'eosio.rex'
)

# File to save the generated keys
keys_file="./eosio_keys.json"
# Initialize the file or clear its contents if it already exists
echo "{" > "$keys_file"

# Import the creator's private key into the wallet, assuming the wallet is already unlocked
# You might want to remove this line if your setup does not require it or handle it differently
cleos wallet import --private-key $creator_private_key --name YourWalletName

# Loop through each account and create it with a new key pair
for account in "${accounts[@]}"; do
# Use cleos to generate the key pair
output=$(cleos create key --to-console)

# Extract the Private and Public key
private_key=$(echo "$output" | grep 'Private key:' | awk '{print $3}')
public_key=$(echo "$output" | grep 'Public key:' | awk '{print $3}')

# Create the new account with the public key
cleos --url $node_url create account $creator $account $public_key $public_key

# Append the keys to the JSON file
echo "\"$account\": { \"private\": \"$private_key\", \"public\": \"$public_key\" }," >> "$keys_file"

echo "Account $account created and keys saved."
done

# To properly close the JSON structure, we need to remove the last comma and add a closing bracket
# This is a bit of a hack, but it works for this script's purposes
sed -i '$ s/,$//' "$keys_file"
echo "}" >> "$keys_file"

echo "All accounts have been created and keys saved to $keys_file."

Empowering this scroll with a touch of the ancient magics:

# This command changes the permissions of the 'activate_features.sh' script to make it executable.
# It grants execution rights to the user, allowing the script to be run as a program.
chmod +x system_accounts.sh

With a commanding gesture, we unleash the power of the scroll, watching as the digital ether swirls and the system guardians take their rightful place within our realm:

# This command executes the 'activate_features.sh' script from the current directory.
# It runs the script that is designed to activate certain features on the Antelope blockchain.
./system_accounts.sh

open the produced file

nano system_accounts.sh

and the result is

{
"eosio.bpay": { "private": "5JuM1eKpeR9Sc26bXWWjTj9AkY3XCTq2NtMShwcP4KdP9DQLk1q", "public": "EOS6Bu7jsAoedQKL2iRjEmDrapdVVcaGzquT6NoBDcJ3ZaC6vg1TH" },
"eosio.msig": { "private": "5KeyMTbHb8ZR9CEevougcoqo81kp2ZcJ3TLEBYCTDNxBQxY17Wd", "public": "EOS6XJk3YUiSt8BnV2ENKd34VubZE6jvPUwenagHUc495z24CDHXE" },
"eosio.names": { "private": "5JnR8iR2bZsyJmTbLE4ZHWFkB8f5B3ZsXHPp9jgBfmZcM7tQt7a", "public": "EOS6sRX3AtBrqPcVTmHUXPD15MBKAzcbs7LPVFNEgyTzXgQZuf12p" },
"eosio.ram": { "private": "5K3xb3oLerdNFLQD1J2djffS6K4sWN6pYs5EjhrsjaZXJzMZV8T", "public": "EOS8f14ieotSGnZunGqaAvvJxXUFWnHY1hGLCXpEZqrj8dNTyL5Sz" },
"eosio.ramfee": { "private": "5JHSXVijUPTTqjjDaZXooFDPiU79ixMa1jyfnrB8qtkLJdQaCBV", "public": "EOS8bDcT7MpY3z4eMw8CgK23GwyQjDNYB1vHoopBXZ1DfcSvenYJ4" },
"eosio.saving": { "private": "5Jufpp5t6iAzMUzpLXCkFLc3AVXE5gcP6C4sszhWAeZyVCyJToK", "public": "EOS87NLcpeGtEXdsMnsLciyMry3QSJm8DcKLj6cBvzdXycPq21xVW" },
"eosio.stake": { "private": "5Jm4D96N4Cx3yBRjz541qzYFjnY1T6ZnEYm7jRyugpqYVGjyTeh", "public": "EOS86RAxHnaLS2spTFEZeTW8M828KiiyqvebFXZZTpAyQ5WDHdGZz" },
"eosio.token": { "private": "5JyDFserGW7NbngdNjXmxVmn5f9g1KmiLSsKiTwBaYGwsLjQgJN", "public": "EOS58cRW9j23p9uB55i4LisnAdR9MhYSWmuYn74wcbCh2MDaTgNjL" },
"eosio.vpay": { "private": "5JXBqApW4Hzpy9tqmfT1TW43Gffnd1iuDV2uYUTQkkM8bpUCsFT", "public": "EOS8CSBfBqMSQhAciknoUR5xHwuk8mzSvLdfaLZWSrN9RdYnNEq9B" },
"eosio.rex": { "private": "5JruRe7uZCRekJgUrUNfsj3o2YtdvRYgBo6mj2s1fLeS43b8TLu", "public": "EOS75bU6i1ZVwiqHQpox4uVQPYu16qjb59qQBroZjPzW2MV6KxiPr" }
}

Act 10: Minting the Currency of Power

In the final act of our creation saga, we seek to mint the currency that will fuel the dreams and destinies of our realm’s inhabitants. This sacred process involves invoking the essence of the eosio.token guardian and bestowing upon it the power to create and issue the GOLD currency.

# Navigate to the directory where the compiled contracts are located, specifically the 'eosio.bios' contract within the 'reference-contracts' project. This directory contains the contract files needed to deploy 'eosio.bios' to the blockchain.
cd /tmp/reference-contracts/build/contracts

# Open an existing wallet using 'cleos'. This command prepares the wallet for further interactions, such as key management and signing transactions. If the wallet is already open, this command has no effect, but it's necessary to run it before performing operations that require wallet access if the wallet has been closed or if the 'keosd' wallet daemon has been restarted. It ensures the wallet is unlocked and ready to use, but note that opening the wallet does not automatically unlock it; you will need to use 'cleos wallet unlock' with your wallet's password for that.
cleos wallet open

# Unlock an already opened wallet using 'cleos'. This command makes the private keys stored within the wallet accessible for signing transactions or performing other operations requiring authentication. Upon execution, you will be prompted to enter the wallet's password. This step is critical for security, ensuring that only authorized users can access and use the private keys. Remember, the wallet must be opened before it can be unlocked. If the wallet is not open, use 'cleos wallet open' first. This command is essential for any blockchain operation that requires transaction signing or key management.
cleos wallet unlock

# import private kety for eosio.token
cleos wallet import --private-key 5JyDFserGW7NbngdNjXmxVmn5f9g1KmiLSsKiTwBaYGwsLjQgJN

# Open an existing wallet using 'cleos'. This command prepares the wallet for further interactions, such as key management and signing transactions. If the wallet is already open, this command has no effect, but it's necessary to run it before performing operations that require wallet access if the wallet has been closed or if the 'keosd' wallet daemon has been restarted. It ensures the wallet is unlocked and ready to use, but note that opening the wallet does not automatically unlock it; you will need to use 'cleos wallet unlock' with your wallet's password for that.
cleos wallet open

# Unlock an already opened wallet using 'cleos'. This command makes the private keys stored within the wallet accessible for signing transactions or performing other operations requiring authentication. Upon execution, you will be prompted to enter the wallet's password. This step is critical for security, ensuring that only authorized users can access and use the private keys. Remember, the wallet must be opened before it can be unlocked. If the wallet is not open, use 'cleos wallet open' first. This command is essential for any blockchain operation that requires transaction signing or key management.
cleos wallet unlock

#Create the GOLD token. This involves calling the create action of the eosio.token contract.
cleos push action eosio.token create '[ "eosio", "1000000000.00 GOLD"]' -p eosio.token@active

#Issue the GOLD token.
cleos push action eosio.token issue '[ "eosio", "1000000000.00 GOLD", "initial supply" ]' -p eosio@active

As the golden essence fills the treasury of our realm, we stand at the dawn of a new era. Our kingdom, now vibrant with the magic of the blockchain, is a testament to the power of creation and unity. Our tale, however, is far from over. The adventure continues, ever-expanding into new horizons and challenges.

Await the next chapter, where we delve deeper into the mysteries of the Antelope blockchain, exploring realms yet unseen and powers untold. The journey is endless, and the legend of our digital kingdom is just beginning.

Part 3 >>

--

--