This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a sample script that deploys that contract.
Note This setup is not required when using a local development blockchain (like celo-devchain or Ganache).
- Create a
.env
file similar to.env.example
. - Paste the private key in
.env
.note: depending on how you generate your private key, you may have to prepend
0x
in the private key does not already have it prepended. - Faucet your account with the Alfajores testnet faucet here.
- Write your contracts in
./contracts
. - Update contract deployment scripts in
./deploy
scripts. - Deploy contracts with
yarn deploy
from the root directory. The default deployment network is specified inhardhat.config.js
and is set toalfajores
initially. - You can specify a specific network deployment directly with
npx hardhat deploy --network [network name]
Network configs are defined in hardhat.config.js
.
You can easily verify your contracts deployed to the associated networks with hardhat-celo.
npx hardhat verify smart-contract-address parameter(s) --network alfajores
On Mainnet:
npx hardhat verify smart-contract-address parameter(s) --network celo
Additionally, you can easily verify your contracts deployed to the associated networks with the following commands.
On Alfajores:
npx hardhat --network alfajores sourcify
On Mainnet:
npx hardhat --network celo sourcify
Deploy with Figment Datahub
Figment Datahub provides RPC & REST APIs for Celo network. To learn more about Datahub refer this doc - https://docs.figment.io/introduction/what-is-datahub. Follow these steps to deploy your smart contract with Figment datahub's RPC.
- Create account on Datahub.
- On the dashboard, click on
Create new app
and select Celo from the protocol list. - Once you have created an app, copy the api key.
- Edit
hardhat.config.js
and updatealfajoresDatahub
andceloDatahub
with the API Key. - Run the test or deploy the contract with following commands.
npx hardhat run scripts/deploy.ts --network alfajoresDatahub
npx hardhat run scripts/deploy.ts --network celoDatahub