I have this in the hardhat.config.js :
require("@nomiclabs/hardhat-waffle")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")
require("solidity-coverage")
require("hardhat-gas-reporter")
require("hardhat-contract-sizer")
require("dotenv").config()
/**
* @type import('hardhat/config').HardhatUserConfig
*/
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
const REPORT_GAS = process.env.REPORT_GAS || false
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 31337,
},
localhost: {
chainId: 31337,
},
rinkeby: {
url: RINKEBY_RPC_URL,
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
saveDeployments: true,
chainId: 4,
blockConfirmations: 8,
},
},
etherscan: {
// npx hardhat verify --network <NETWORK> <CONTRACT_ADDRESS> <CONSTRUCTOR_PARAMETERS>
apiKey: {
rinkeby: ETHERSCAN_API_KEY,
},
},
gasReporter: {
enabled: REPORT_GAS,
currency: "USD",
outputFile: "gas-report.txt",
noColors: true,
// coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
contractSizer: {
runOnCompile: false,
only: ["Raffle"],
},
namedAccounts: {
deployer: {
default: 0,
1: 0,
},
player: {
default: 1,
},
},
solidity: {
compilers: [
{
version: "0.8.7",
},
{
version: "0.4.24",
},
],
},
mocha: {
timeout: 200000, // 200 seconds max for running tests
},
}
and this in a file called helper-hardhat-config.js:
const networkConfig = {
1337: {
name: 'localhost',
gasLane:
'0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc', // 30 gwei
mintFee: '1000000000000000000', // 1 ETH
callbackGasLimit: '500000', // 500,000 gas
subscriptionId: 'xxxx', // our own ID
},
4: {
name: 'rinkeby',
vrfCoordinatorV2: '0x6168499c0cFfCaCD319c818142124B7A15E857ab',
gasLane:
'0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc',
callbackGasLimit: '500000', // 500,000 gas
mintFee: '100000000000000000', // 0.1 ETH
subscriptionId: 'xxxx', // our own ID
},
}
const developmentChains = ['hardhat', 'localhost']
module.exports = {
networkConfig,
developmentChains,
}