-
Notifications
You must be signed in to change notification settings - Fork 4
/
hardhat.config.js
88 lines (85 loc) · 2.93 KB
/
hardhat.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-ethers");
require("hardhat-deploy");
require("hardhat-gas-reporter");
require("solidity-coverage");
const dotenv = require("dotenv");
const { BN, Address, toChecksumAddress } = require("ethereumjs-util");
dotenv.config();
task("compute-contract-address", "Computes contract address.")
.addParam("account", "The account's address")
.addOptionalParam("nonce", "Custom nonce. Default: next nonce.")
.setAction(async (taskArgs, { ethers, config, network }, hre) => {
let nonce;
if (!taskArgs.nonce) {
process.stdout.write("Fetching next nonce...\r");
const web3provider = new ethers.providers.JsonRpcProvider(network.config);
nonce = await web3provider.getTransactionCount(taskArgs.account);
process.stdout.write(`Nonce: ${nonce} \n`);
} else nonce = taskArgs.nonce;
const deployAddress = Address.generate(Address.fromString(taskArgs.account), new BN(String(nonce)));
const checksumAddress = toChecksumAddress(deployAddress.toString());
console.log(`If ${taskArgs.account} would deploy a contract in ${nonce}th transaction, it's address would be ${checksumAddress} .`);
return checksumAddress;
});
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
compilers: [
{
version: "0.8.4",
},
{
version: "0.7.6",
settings: {},
},
],
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
deploy: "./deploy",
},
networks: {
main: {
chainId: 1,
url: `https://mainnet.infura.io/v3/${process.env?.INFURA_PROJECT_ID}` || "",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
hardhat: {
initialBaseFeePerGas: 0, // workaround from https://github.com/sc-forks/solidity-coverage/issues/652#issuecomment-896330136 . Remove when that issue is closed.
},
goerli: {
chainId: 5,
url: `https://goerli.infura.io/v3/${process.env?.INFURA_PROJECT_ID}` || "",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
gnosis: {
chainId: 100,
url: "https://rpc.gnosischain.com" || "",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
sepolia: {
chainId: 11155111,
url: `https://sepolia.infura.io/v3/${process.env.INFURA_PROJECT_ID}`,
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
chiado: {
chainId: 10200,
url: "https://gnosis-chiado-rpc.publicnode.com",
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN,
},
};