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.
Let's create a hardhat project using npx hardhat init now. We are using a JavaScript template from the list of options to facilitate the deployment and choosing the configuration for the project as shown below.
√ What do you want to do? · Create a JavaScript project
√ Hardhat project root: · \Users\...\plume-hardhat
√ 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
We'll be using a sample contract, you can replace this with your own codebase. Make sure you place the contract in "Contracts" directory within your Hardhat project.
Sample Smart Contract Code
This is a sample NFT contract based on OpenZeppelin's open-source ERC-721 implementation to tokenize our CBO's prized Rolex watch on Plume.
Contracts/RolexYachtMaster40.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract RolexYachtMaster40 is Ownable, ERC721 {
error NFTAlreadyMinted();
bool private _minted;
constructor() Ownable(msg.sender) ERC721("Rolex Yacht-Master 40", "") {}
function mint() public onlyOwner returns (uint256) {
if (_minted) {
revert NFTAlreadyMinted();
}
_safeMint(owner(), 0);
_minted = true;
return 0;
}
}
Compile the contract(s) using the below command:
npx hardhat compile
Let's create a ignition module to deploy the contract(s). Create a file as <Your-Contract>.js at ignition/modules/<Your-Contract>.js . Here's a sample module we used with the above sample contract.