DeFi, NFTs, and Metaverse’s first Cosmos EVM chain, the Cronos chain has been buzzing the Cryptoverse since its promising launch. The cross-ecosystem interoperating blockchain network, Cronos, is affordable, with enhanced throughput and speedy finality.
Geared towards scaling the DeFi and Web3 communities, Cronos chain offers swift porting of apps and cryptocurrencies across chains. Cronos chain is a Cosmos SDK-built chain that operates swiftly with IBC across various Cosmos ecosystem chains.
dApp building on the Cronos mainnet Beta cronosmainnet_25-1 requires developing a fully-functional node for running events and executing queries. Running Cronos Mainnet Beta nodes has the following machine system prerequisites: 4-core, x86_64 architecture processor with 16 GB RAM and a storage space of 1 TB.
Preparing an AWS EC2 Machine with Flexible Storage
After signing-in to the AWS Console, select Amazon Linux 2 Kernel 5 64-bit (x86) as the machine to be used. A t2 or t3 machine having 4 cores or a x86_64 architecture processor with 16 GB of RAM would suffice. Ensure having enough provisions made to oversee the /dev/sdb (root and EBS) volume as later on increasing the elastic storage could be required.
Then decide on a Name Tag to easily identify the said instance in the AWS Management Console (MC). Lastly, prepare a Security Group (SG) with default settings selected.
A private key pair (.pem file) must then be created, downloaded and saved in your computer device (in an easily accessible directory—for instance ~/cronosdir).
Link with EC2 VM a Dedicated IP Address
Access the ‘Allocate Elastic IP address’ button on the right top corner of the EC2 MC. Then click on the ‘Actions’ button on its left for associating it with the EC2 VM.
Port 8545 for RPC-JSON Queries
Sending RPC-JSON queries requires opening port 8545 in the EC2 MC. You can do it via accessing the Instances button, and then the security group associated with your VM. Select ‘Edit Inbound Rules’ option given under the Security Groups menu, via selecting the SG linked with your VM. To connect to the AWS EC2 instance, use these commands in a Terminal window.
AWS EC2 Instance Connection
Initiate the following commands in a ~/cronosdir directory Terminal window:
Fix the permissions of the key pair file
chmod 400 cronos-01.pem
Connect to the EC2 virtual machine
ssh -i "cronos-01.pem" ec2-user@elastic_ip_associated_with_vm
Once connected, update libraries and install missing ones
sudo yum update
sudo yum install jq
Extra Storage Mounting for the Blockchain Data
Keeping the EC2 virtual machine connected, initiate these commands in the Terminal:
List available storage volumes – Here you can retrieve the File system name of the 1000 GB volume, which should be something like /dev/nvme1n1
lsblk
List UUIDs of available storage volumes, Here you can retrieve the UUID of the 1000 GB volume, which should be something like 0bcd4d37-a271-4b2c-a475-a2bdb05f5f0d
sudo blkid
Mount the 1000 GB volume and associate it with /cronos directory, Replace /dev/nvme1n1 and 0bcd4d37-a271-4b2c-a475-a2bdb05f5f0d by the correct values in the following commands
sudo mkfs -t xfs /dev/nvme1n1
sudo mkdir /cronos
sudo mount /dev/nvme1n1 /cronos
Let’s edit the file /etc/fstab
sudo vim /etc/fstab
With your terminal having the /etc/fstab file opened, insert the following row below the file:
UUID=3a5c2d89-be70-4d9b-8597-e20af21db901 /cronos xfs defaults,nofail 0 2
Alter the /cronos directory permissions to enable its writability and executability via the Cronos client:
Installing the Cronos Mainnet Binary Client (cronosd)
While still connected to the VM in your terminal, go to the user directory
cd ~/
Replace the URL below by the latest URL given in the official documentation at https://cronos.crypto.org/docs/getting-started/cronos-mainnet.html#step-1-get-the-cronos-mainnet-beta-binary
curl -LOJ <https://github.com/crypto-org-chain/cronos/releases/download/v0.6.1/cronos_0.6.1_Linux_x86_64.tar.gz>
Replace the file name below by the correct file name if needed
tar -zxvf cronos_0.6.1_Linux_x86_64.tar.gz
We check that cronosd has been installed to the ~/bin/cronosd directory, this command should return the version number ./bin/cronosd version, We move cronosd to the main bin directory, then check that cronosd can be called from anywhere. The last command should return the version number.
sudo mv ./bin/cronosd /bin
cronosd version
Initializing Cronosd
Start cronos d’s Initialization.
Replace [moniker] by the name that we want to give to our node. Replace cronosmainnet_25-1 by the correct value if it has changed. Note that we use the –home option to make sure that the cronos data is stored on the mounted 1000 GB drive, not on the root volume.
cronosd init [moniker] --chain-id cronosmainnet_25-1 --home /cronos/.cronos
Archive node configuration of cronosd
Change the node’s configuration to make sure safe storage of blocks and transactions. First un-toggle fast sync, then deactivate pruning.
Edit the /cronos/.cronos/config/config.toml file
vim /cronos/.cronos/config/config.toml
fast_sync should be changed to false and saved in config.toml,
fast_sync = false
Edit app.toml.
vim /cronos/.cronos/config/app.toml
Convert pruning from default to nothing in app.toml and save it.
pruning = "nothing"
Keep cronos’ configuration continue
The genesis file must be downloaded and saved in the following directory; /cronos/.cronos/config/
curl <https://raw.githubusercontent.com/crypto-org-chain/cronos-mainnet/master/cronosmainnet_25-1/genesis.json> > /cronos/.cronos/config/genesis.json
Initiate the following command for ending the configuration. Verify sha256sum checksum of the downloaded genesis.json. You should see OK! if the sha256sum checksum matches.
if [[ $(sha256sum ~/.cronos/config/genesis.json | awk '{print $1}') = "58f17545056267f57a2d95f4c9c00ac1d689a580e220c5d4de96570fbbc832e1" ]]; then echo "OK"; else echo "MISMATCHED"; fi;
In cronos/.cronos/config/app.toml, update minimum gas price
if [[ $(sha256sum /cronos/.cronos/config/genesis.json | awk '{print $1}') = "58f17545056267f57a2d95f4c9c00ac1d689a580e220c5d4de96570fbbc832e1" ]]; then echo "OK"; else echo "MISMATCHED"; fi;
sed -i.bak -E 's#^(minimum-gas-prices[[:space:]]+=[[:space:]]+).*$#\\1"5000000000000basecro"#' /cronos/.cronos/config/app.toml
For network configuration, in cronos/.cronos/config/config.toml, to modify the configurations of persistent_peers, we create_empty_blocks_interval and timeout_commit
sed -i.bak -E 's#^(seeds[[:space:]]+=[[:space:]]+).*$#\\1"0d5cf1394a1cfde28dc8f023567222abc0f47534@cronos-seed-0.crypto.org:26656,3032073adc06d710dd512240281637c1bd0c8a7b@cronos-seed-1.crypto.org:26656,04f43116b4c6c70054d9c2b7485383df5b1ed1da@cronos-seed-2.crypto.org:26656"#' /cronos/.cronos/config/config.toml
sed -i.bak -E 's#^(create_empty_blocks_interval[[:space:]]+=[[:space:]]+).*$#\\1"5s"#' /cronos/.cronos/config/config.toml
sed -i.bak -E 's#^(timeout_commit[[:space:]]+=[[:space:]]+).*$#\\1"5s"#' /cronos/.cronos/config/config.toml
Generate keys and initiate the below mentioned command. Select a password and save it. A mnenomic phrase will be given which must be saved safely as well.
cronosd keys add Default
Cronosd client initialization
At this point, creating a cronosd service is required to enable starting the cronosd client upon restarting the virtual machine.
curl -s <https://raw.githubusercontent.com/crypto-org-chain/cronos-docs/master/systemd/create-service.sh> -o create-service.sh && curl -s <https://raw.githubusercontent.com/crypto-org-chain/cronos-docs/master/systemd/cronosd.service.template> -o cronosd.service.template
chmod +x ./create-service.sh && ./create-service.sh
Edit the /etc/systemd/system/cronosd.service file
sudo vim /etc/systemd/system/cronosd.service
The ExecStart line must be changed to as follows and saved:
ExecStart=/usr/bin/cronosd start --home /cronos/.cronos
After it, do the following:
sudo systemctl daemon-reload
sudo systemctl start cronosd
Check node’s sync progress (in number of blocks). You can compare the number of blocks to the one shown in the Cronos block explorer at the URL https://cronos.crypto.org/explorer/
cronosd status 2>&1 | jq '.SyncInfo.latest_block_height'
Stop cronosd service
sudo systemctl stop cronosd
Query your node remotely
After full node’s syncing completion, sending any JSON-RPC query to the node in a remote manner becomes possible via the standard Ethereum request formats.
Happy dApps building to you!