Skip to content

Commit

Permalink
added: minimal boilerplate with v3 toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Salmandabbakuti committed Sep 30, 2023
1 parent e9fc847 commit 981d1b1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 128 deletions.
5 changes: 1 addition & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Be aware. dont commit this file or any of theses keys to your repo.
PRIVATE_KEY=
POLYGON_MUMBAI_RPC_URL=
POLYGON_MAINNET_RPC_URL=
ETHERSCAN_API_KEY=
PRIVATE_KEY=
47 changes: 0 additions & 47 deletions .github/workflows/ci.yml

This file was deleted.

15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# hardhat-boilerplate
# minimal-hardhat-boilerplate

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts with balances.

Expand All @@ -14,12 +14,6 @@ npm install
# starts local node
npx hardhat node

# list accounts with balances
npx hardhat accounts

# show balance eth of specified account
npx hardhat balance --account '0x47a9...'

# compile contracts
npx hardhat compile

Expand All @@ -29,8 +23,8 @@ npx hardhat deploy --network local
# deploy contract in scripts/deploy.js on specified network
npx hardhat run scripts/deploy.js --network local

#check linter issues using solhint plugin
npx hardhat check
# verify contract
npx hardhat verify --network <deployed network> <deployed contract address> "<constructor1>" "<constructor2>"

# check coverage using solidity-coverage plugin: supports hardhat network only
npx hardhat coverage --network hardhat
Expand All @@ -41,9 +35,6 @@ npx hardhat test
# remove all compiled and deployed artifacts
npx hardhat clean

# verify contract
npx hardhat verify --network <deployed network> <deployed contract address> "<constructor1>" "<constructor2>"

# show help
npx hardhat help
```
61 changes: 2 additions & 59 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,25 @@
require('@nomicfoundation/hardhat-toolbox');
require('@nomicfoundation/hardhat-chai-matchers');
require("@nomiclabs/hardhat-solhint");
require('dotenv').config();

// defining accounts to reuse.
const accounts = process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [];

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("hello", "Prints Hello World", () => console.log("Hello World!"));

task("accounts", "Prints the list of accounts with balances", async () => {
const accounts = await ethers.getSigners();
const provider = await ethers.provider;

for (const account of accounts) {
const balance = await provider.getBalance(account.address);
console.log(`${account.address} - ${ethers.formatEther(balance)} ETH`);
}
});

task("deploy", "Deploys Contract", async () => {
const contract = await ethers.deployContract("Greeter", ["Hello, Hardhat!"]);
await contract.waitForDeployment();
console.log("contract deployed at:", contract.target);
});

task("balance", "Prints an account's balance")
.addParam("account", "The account's address")
.setAction(async ({ account }) => {
const provider = await ethers.provider;
const balance = await provider.getBalance(account);
console.log(ethers.formatEther(balance), "ETH");
});


module.exports = {
solidity: "0.8.19",
defaultNetwork: "local",
networks: {
hardhat: {
chainId: 1337
},
local: {
url: "http://127.0.0.1:8545",
},
mumbai: {
url: process.env.POLYGON_MUMBAI_RPC_URL || "https://rpc-mumbai.maticvigil.com",
url: "https://rpc-mumbai.maticvigil.com",
accounts
},
polygon: {
url: process.env.POLYGON_MAINNET_RPC_URL || "https://rpc-mainnet.maticvigil.com",
accounts
}
},
etherscan: {
// API key for Polygonscan
apiKey: process.env.ETHERSCAN_API_KEY
},
gasReporter: {
enabled: true,
currency: "USD",
},
solidity: {
version: "0.8.19",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
};
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{
"name": "hardhat-boilerplate",
"name": "hardhat-boilerplate-minimal",
"version": "1.0.0",
"description": "hardhat and ethersjs boilerplate for Dapp development",
"description": "Minimal hardhat boilerplate for Dapp development",
"main": "index.js",
"scripts": {
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"deploy": "npx hardhat deploy",
"coverage": "npx hardhat coverage --network hardhat"
"deploy": "npx hardhat deploy"
},
"keywords": [],
"author": "Salman Dabbakuti",
"license": "ISC",
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.2",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomiclabs/hardhat-solhint": "^3.0.1",
"dotenv": "^16.3.1",
"hardhat": "^2.17.4"
}
Expand Down

0 comments on commit 981d1b1

Please sign in to comment.