Skip to main content

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 with Caldera’s Ethereum API, allowing for the deployment of smart contracts into the Caldera 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

  1. Create a directory for your project:
  2. Initialize the project, which will create a package.json file
  3. Install Hardhat
  4. Create a project
  5. Create an empty hardhat.config.js and install the Ethers plugin to use the Ethers.js library to interact with the network.

Creating Your Smart Contract

  1. Create a contracts directory
  2. Create 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.
  1. Create a secrets.json file to store your private key
  2. Add your private key to secrets.json
  3. Add the file to your project’s .gitignore, and never reveal your private key.
  4. Modify the hardhat.config.js file
    • Import the Ethers.js plugin
    • Import the secrets.json file
    • Inside the module.exports add the Caldera network configuration
    hardhat.config.js

Deploying Your Smart Contract

  1. Compile the contract
  2. Create a new directory for the script and name it scripts and add a new file to it called deploy.js
  3. Create a deployment script, like the one below
    scripts/deploy.js
  4. Deploy your_contract.sol using the command below