Hardhat
Deploying Smart Contracts using Hardhat
What is Hardhat?β
Hardhat is a development environment for Ethereum that helps developers manage and automate the common tasks involved in building smart contracts and decentralized applications. It can directly interact withAtleta Olympia's Ethereum API, allowing for the deployment of smart contracts into the Atleta Olympia network. Additionally, Hardhat is a comprehensive set of tools for creating Ethereum-based software, which includes various components that aid in editing, compiling, debugging, and deploying smart contracts and decentralized applications. All of these components work together to create a complete development environment.
Creating a Hardhat Projectβ
Create a directory for your project
mkdir hardhat && cd hardhatInitialize the project which will create a package.json file
npm init -y3.Install Hardhat
npm install hardhat4.Create a project
npx hardhat5.Create an empty hardhat.config.js and install the Ethers plugin to use the Ethers.js library to interact with the network.
npm install @nomiclabs/hardhat-ethers ethersCreating your Smart Contractβ
Create a contracts directory
mkdir contracts && cd contractsCreate your_contract.sol file in contracts directory
Creating your Configuration Fileβ
Modify the Hardhat configuration file and create a secure file to store your private key in.
Create a secrets.json file to store your private key
Add your private key to secrets.json
Add the file to your project's .gitignore, and never reveal your private key.
Modify the hardhat.config.js file
Import the Ethers plugin
Import the secrets.json file
Inside the module.exports add the Atleta Olympia network configuration
Deploying your Smart Contractβ
Compile the contract
Create a new directory for the script and name it scripts and add a new file to it called deploy.js
Create a deployment script, like the one below
Deploy your_contract.sol using the command below
Last updated