Hardhat
Hardhat is an open-source development environment designed to provide developers with a flexible and extensible framework for building, testing, and deploying smart contracts.
While originally created for the Ethereum blockchain, the Filecoin Ethereum Virtual Machine runtime (FEVM) allows Hardhat to be used to develop and deploy smart contracts on the Filecoin network.
Quickstart
The FEVM Hardhat kit is a starter hardhat project for developing, deploying, and testing Solidity smart contracts on the Filecoin network. It functions in the same way as other Hardhat development kits. Check out the quickstart below to test it out!
Prerequisites
This guide assumes you have the following installed:
A Filecoin address stored in MetaMask
Environment setup
First, we need to grab the starter kit and install the dependencies.
Clone the Hardhat starter kit and move into the new
fevm-hardhat-kitdirectory:
git clone https://github.com/filecoin-project/fevm-hardhat-kit.git
cd fevm-hardhat-kit
# Cloning into 'fevm-hardhat-kit'...
# remote: Enumerating objects: 758, done.
# remote: Counting objects: 100% (725/725), done.
#
# ...Use Yarn to install the project’s dependencies:
Add your private key to the
.envfile:
Get the addresses associated with the private key from Hardhat:
Now that we’ve got the kit set up, we can start using it to develop and deploy our contracts.
Manage the contracts
There are two main types of contracts:
Basic Solidity examples: Simple contracts to show off basic Solidity.
Filecoin API Examples: Contracts that demo how to use the Filecoin APIs in Solidity to access storage deals and other Filecoin-specific functions.
Make sure that your account has funds. You won’t be able to deploy any contracts without FIL or tFIL.
Run
hardhat deployto deploy all the contracts. This can take a few minutes:
Interact with the contracts using the available functions within the
tasksfolder. For example, you can get the balance of thesimple-coincontract by calling theget-balancefunction:
Hardhat docs
You can view the official Hardhat documentation over at hardhart.org/docs.
Last updated
Was this helpful?