Hardhat is a development environment for Ethereum software. It consists of different components for editing, compiling, debugging and deploying your smart contracts and dApps, all of which work together to create a complete development environment.For more information please visit: Hardhat Webpage
SIX EVM on mainnet and testnet currently support solidity below version 0.8.20
Quick Start
To create the sample project, run npx hardhat init in your project folder:
$ npx hardhat init888 888 888 888 888888 888 888 888 888888 888 888 888 8888888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888888 888 "88b 888P" d88" 888 888 "88b "88b 888888 888 .d888888 888 888 888 888 888 .d888888 888888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888👷 Welcome to Hardhat v2.22.12 👷? What do you want to do? …❯ Create a JavaScript project Create a TypeScript project Create a TypeScript project (with Viem) Create an empty hardhat.config.js Quit
Let’s create the JavaScript or TypeScript project and go through these steps to compile, test and deploy the sample contract. We recommend using TypeScript, but if you are not familiar with it just pick JavaScript.
Hardhat Config
if you take a look in the root folder, you'll see hardhat.config.ts :
if you take a look in the contracts/ folder, you'll see Lock.sol:
// SPDX-License-Identifier: UNLICENSEDpragmasolidity ^0.8.13;// Uncomment this line to use console.log// import "hardhat/console.sol";contract Lock {uintpublic unlockTime;addresspayablepublic owner;eventWithdrawal(uint amount, uint when);constructor(uint_unlockTime) payable {require( block.timestamp < _unlockTime,"Unlock time should be in the future" ); unlockTime = _unlockTime; owner =payable(msg.sender); }functionwithdraw() public {// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);require(block.timestamp >= unlockTime,"You can't withdraw yet");require(msg.sender == owner,"You aren't the owner");emitWithdrawal(address(this).balance, block.timestamp); owner.transfer(address(this).balance); }}
To compile it, simply run:
npx hardhat compile
Deploying your contract
Next, to deploy the contract we will use a Hardhat Ignition module.Inside the ignition/modules folder you will find a file with the following code:
// This setup uses Hardhat Ignition to manage smart contract deployments.// Learn more about it at https://hardhat.org/ignitionimport { buildModule } from"@nomicfoundation/hardhat-ignition/modules";constJAN_1ST_2030=1893456000;constONE_GWEI:bigint=1_000_000_000n;constLockModule=buildModule("LockModule", (m) => {constunlockTime=m.getParameter("unlockTime",JAN_1ST_2030);constlockedAmount=m.getParameter("lockedAmount",ONE_GWEI);constlock=m.contract("Lock", [unlockTime], { value: lockedAmount, });return { lock };});exportdefault LockModule;
You can deploy it using npx hardhat ignition deploy ./ignition/modules/Lock.ts --network fivenet
Verify your contract
You can verify Lock.sol:Lock contract by using npx hardhat ignition verify chain-150 --include-unrelated-contracts