Supported protocols • Chainstack blog • Chainstack docs • Blockchain API reference • Start for free
In this tutorial, you will learn how to build a lottery smart contract using Solidity, and how to deploy and verify smart contracts on the Cronos blockchain using Hardhat. This repo serves as the codebase for you to be able to follow along comfortably with the written tutorial on Chainstack's blog:
Cronos is an EVM-compatible layer 1 blockchain, equipped with the unique Inter Blockchain Communications (IBC) protocol powered by the Cosmos SDK. This gives Cronos interoperability between Cosmos and EVM ecosystems.
In this project you will be create, test, deploy and verify a Lottery smart contract on the Cronos Testnet straight from Hardhat's command line.
Clone this repository.
npm install
Run this command at the root of oyur terminal to create a dotenv file:
touch .env
Configure it along the following lines:
RPC_URL=CHAINSTACK_CRONOS_NODE_URL
PRIVATE_KEY=YOUR_PRIVATE_KEY
API_KEY=CRONOSCAN_API_KEY(to verify the smart contract)
Save the dotenv file and run this command in your terminal:
source .env
npx hardhat compile
Run this command to start a local Hardhat node in your terminal:
npx hardhat node
Run the tests on your local node with:
npx hardhat test --network localhost
You already have the deploy script setup in scripts/DeployDutch.js. To dpeloy on Cronos testnet, simply run:
npx hardhat run --network Cronos_testnet scripts/DeployDutch.js
To verify:
npx hardhat verify --network Cronos_testnet {Contract Address}
You now have a deployed and verified smart contract on the Cronos Testnet. Feel free to create your own project from scratch by following along with our blog, linked above.