Hardhat is a flexible and extensible Ethereum development environment used for compiling, testing, debugging, and deploying smart contracts.
This guide walks you through deploying an ERC-721 smart contract on Celeschain Testnet using Hardhat.
By the end of this guide, you will be able to:
Set up Hardhat for Celeschain Testnet
Create an ERC-721 NFT smart contract
Compile the smart contract
Deploy the smart contract to Celeschain Testnet
Interact with the deployed contract using Hardhat
Ensure you have Node.js v18 or higher installed.
Deploying to Celeschain requires gas. Fund your wallet with CLES (native token of Celeschain) from the testnet faucet.
Creating a Project
Start by setting up a new Node.js project:
Install Hardhat:
Create a Hardhat project:
Select:
Create a TypeScript project
Choose yes for .gitignore
Choose yes to load the sample project
Configuring Hardhat for Celeschain
Add Celeschain Testnet to your Hardhat configuration.
Edit hardhat.config.ts:
Load Environment Variables
Install dotenv:
Create .env:
⚠️ Never commit your private key to a public repository!
Writing the NFT Smart Contract
Below is a simple ERC-721 contract that you will deploy:
contracts/NFT.sol:
Install OpenZeppelin:
Delete the default Lock.sol file.
Compiling the Smart Contract
Compile using:
Deploying the Smart Contract
Update scripts/deploy.ts:
Deploy to Celeschain Testnet:
After deployment, view your contract on:
Celeschain Testnet Explorer
https://testnet-explorer.celeschain.xyz