Deploy using Hardhat
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.
Before you Begin
Check if you are using the right network configuration
Have enough test tokens in your wallet
Hardhat Setup
Start by creating a folder plume-hardhat. Open a terminal pointing to this folder and run the below command to initialize a node.js project.
npm init -yFollowed by installing hardhat and other necessary libraries using the below command.
npm install --save-dev hardhat @openzeppelin/contracts @nomicfoundation/hardhat-ignition-ethers dotenvLet'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) · yConfigure and prepping to deploy
Let's create a .env file to store the private key inside it safely.
Make the following adjustments to the auto-generated hardhat.config.js file to prepare to deploy to the Plume Testnet for instance (switch the RPC and verifier URL to Mainnet to deploy on Plume Mainnet):
Import the
hardhat-toolboxandhardhat-ignition-ethersplugin into the Hardhat Runtime Environment.Add the Plume Testnet network details.
Compile and Deploy
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.
Compile the contract(s) using the below command:
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.
Deploy your contract(s) to the Plume Testnet using the following command:
Sample Output
You can view the deployed contract on the Plume Testnet Explorer.
Last updated