Skip to content

A simple funding contract deployment that can fund and withdraw from contract using hardhat development environment.

Notifications You must be signed in to change notification settings

akshtsng/HardhatFundMe

Repository files navigation

Hardhat Fund Me

Getting Started

Requirements

Quickstart

git clone https://github.com/akshtsng/HardhatFundMe
cd hardhat-fund-me
yarn

Usage

Deploy:

yarn hardhat deploy

Testing

yarn hardhat test

Test Coverage

yarn hardhat coverage

Deployment to a testnet or mainnet

  1. Setup environment variables
  • Set GOERLI_RPC_URL and PRIVATE_KEY as environment variables. Add them to a .env file.

  • PRIVATE_KEY: The private key of account (like from metamask). NOTE: FOR DEVELOPMENT, USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.

  • GOERLI_RPC_URL: This is url of the goerli testnet node we're working with. We can get setup with one for free from Alchemy

  1. Get testnet ETH
  1. Deploy
yarn hardhat deploy --network goerli

Scripts

After deploying to a testnet or local net, run the scripts.

yarn hardhat run scripts/fund.js

or

yarn hardhat run scripts/withdraw.js

Estimate gas

Estimate how much gas things cost by running:

yarn hardhat test

We get output file called gas-report.txt

Estimate gas cost in USD

To get a USD estimation of gas cost, we'll need a COINMARKETCAP_API_KEY environment variable. Get one for free from CoinMarketCap.

Verify on etherscan

If we deploy to a testnet or mainnet, we can verify it if we get an API Key from Etherscan and set it as an environemnt variable named ETHERSCAN_API_KEY.

In it's current state, if we have our api key set, it will auto verify goerli contracts!

However, we can manual verify with:

yarn hardhat verify --constructor-args arguments.js DEPLOYED_CONTRACT_ADDRESS

Linting

solhint installation: Documentation

To check linting / code formatting:

yarn lint

or, to fix:

yarn lint:fix

Formatting

yarn format

Thank you!

Akshat Singh Linkedin

About

A simple funding contract deployment that can fund and withdraw from contract using hardhat development environment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published