Deploying a Smart Contract on Cuckoo Chain with Hardhat
This guide walks you through deploying a smart contract on Cuckoo Chain’s Ethereum L2 using Hardhat and TypeScript.
Prerequisites
-
Node.js and npm: Ensure both are installed. Download here.
-
Ethereum Wallet: A private key for the Cuckoo Testnet that has testnet $CAI. Get it from Testnet Faucets. Use a new wallet without real funds for security.
-
Basic Solidity and CLI knowledge: Helpful but not mandatory!
What You'll Learn
- Setting up a TypeScript-based Hardhat project.
- Writing a simple Ethereum smart contract.
- Configuring Hardhat for Cuckoo Testnet.
- Deploying your smart contract on Cuckoo.
Step 1: Initialize a Hardhat TypeScript Project
Open your terminal and create a new project directory, then navigate into it:
mkdir my-hardhat-project && cd my-hardhat-project
Initialize an npm project:
npm init -y
Install the necessary packages for Hardhat and TypeScript:
npm install --save-dev hardhat ts-node typescript @nomiclabs/hardhat-ethers ethers
Start a new Hardhat project with TypeScript:
npx hardhat init
Follow the prompts:
- Choose "Create a TypeScript project".
- Select "Yes" for adding a
.gitignore
. - Select "Yes" for installing the sample project's dependencies.
[~/Cuckoo/my-hardhat-project]$ npx hardhat
888 888 888 888 888
888 888 888 888 888
888 888 888 888 888
8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
888 888 88b 888P d88 888 888 88b 88b 888
888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 Y888888 888 Y88888 888 888 Y888888 Y888
👷 Welcome to Hardhat v2.18.2 👷
✔ What do you want to do? · Create a TypeScript project
✔ Hardhat project root: · /Users/Cuckoo/my-hardhat-project
✔ Do you want to add a .gitignore? (Y/n) · y
✔ Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox)? (Y/n) · y