-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Migration to Hardhat v3 #1192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Migration to Hardhat v3 #1192
Changes from 8 commits
45ba40e
3c511f9
3fc0aa6
c337c4e
0732655
6405e0a
d219701
285c39f
5f20444
68a64aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| import * as dotenv from "dotenv"; | ||
| dotenv.config(); | ||
| import { HardhatUserConfig } from "hardhat/config"; | ||
| import "@nomicfoundation/hardhat-ethers"; | ||
| import "@nomicfoundation/hardhat-chai-matchers"; | ||
| import "@typechain/hardhat"; | ||
| import "hardhat-gas-reporter"; | ||
| import "solidity-coverage"; | ||
| import "@nomicfoundation/hardhat-verify"; | ||
| import "hardhat-deploy"; | ||
| import "hardhat-deploy-ethers"; | ||
| import { task } from "hardhat/config"; | ||
| import generateTsAbis from "./scripts/generateTsAbis"; | ||
|
|
||
| // If not set, it uses the hardhat account 0 private key. | ||
| // You can generate a random account with `yarn generate` or `yarn account:import` to import your existing PK | ||
| const deployerPrivateKey = | ||
| process.env.__RUNTIME_DEPLOYER_PRIVATE_KEY ?? "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"; | ||
| // If not set, it uses our block explorers default API keys. | ||
| const etherscanApiKey = process.env.ETHERSCAN_V2_API_KEY || "DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW"; | ||
|
|
||
| // If not set, it uses ours Alchemy's default API key. | ||
| // You can get your own at https://dashboard.alchemyapi.io | ||
| const providerApiKey = process.env.ALCHEMY_API_KEY || "cR4WnXePioePZ5fFrnSiR"; | ||
|
|
||
| const config: HardhatUserConfig = { | ||
| solidity: { | ||
| compilers: [ | ||
| { | ||
| version: "0.8.20", | ||
| settings: { | ||
| optimizer: { | ||
| enabled: true, | ||
| // https://docs.soliditylang.org/en/latest/using-the-compiler.html#optimizer-options | ||
| runs: 200, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| defaultNetwork: "localhost", | ||
| namedAccounts: { | ||
| deployer: { | ||
| // By default, it will take the first Hardhat account as the deployer | ||
| default: 0, | ||
| }, | ||
| }, | ||
| networks: { | ||
| // View the networks that are pre-configured. | ||
| // If the network you are looking for is not here you can add new network settings | ||
| hardhat: { | ||
| forking: { | ||
| url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`, | ||
| enabled: process.env.MAINNET_FORKING_ENABLED === "true", | ||
| }, | ||
| }, | ||
| mainnet: { | ||
| url: "https://mainnet.rpc.buidlguidl.com", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| sepolia: { | ||
| url: `https://eth-sepolia.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| arbitrum: { | ||
| url: `https://arb-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| arbitrumSepolia: { | ||
| url: `https://arb-sepolia.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| optimism: { | ||
| url: `https://opt-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| optimismSepolia: { | ||
| url: `https://opt-sepolia.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygon: { | ||
| url: `https://polygon-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygonAmoy: { | ||
| url: `https://polygon-amoy.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygonZkEvm: { | ||
| url: `https://polygonzkevm-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygonZkEvmCardona: { | ||
| url: `https://polygonzkevm-cardona.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| gnosis: { | ||
| url: "https://rpc.gnosischain.com", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| chiado: { | ||
| url: "https://rpc.chiadochain.net", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| base: { | ||
| url: "https://mainnet.base.org", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| baseSepolia: { | ||
| url: "https://sepolia.base.org", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| scrollSepolia: { | ||
| url: "https://sepolia-rpc.scroll.io", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| scroll: { | ||
| url: "https://rpc.scroll.io", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| celo: { | ||
| url: "https://forno.celo.org", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| celoSepolia: { | ||
| url: "https://forno.celo-sepolia.celo-testnet.org/", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| }, | ||
| // Configuration for harhdat-verify plugin | ||
| etherscan: { | ||
| apiKey: `${etherscanApiKey}`, | ||
| }, | ||
| // Configuration for etherscan-verify from hardhat-deploy plugin | ||
| verify: { | ||
| etherscan: { | ||
| apiKey: `${etherscanApiKey}`, | ||
| }, | ||
| }, | ||
| sourcify: { | ||
| enabled: false, | ||
| }, | ||
| }; | ||
|
|
||
| // Extend the deploy task | ||
| task("deploy").setAction(async (args, hre, runSuper) => { | ||
| // Run the original deploy task | ||
| await runSuper(args); | ||
| // Force run the generateTsAbis script | ||
| await generateTsAbis(hre); | ||
| }); | ||
|
|
||
| export default config; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,18 @@ | ||
| import * as dotenv from "dotenv"; | ||
| dotenv.config(); | ||
| import { HardhatUserConfig } from "hardhat/config"; | ||
| import "@nomicfoundation/hardhat-ethers"; | ||
| import "@nomicfoundation/hardhat-chai-matchers"; | ||
| import "@typechain/hardhat"; | ||
| import "hardhat-gas-reporter"; | ||
| import "solidity-coverage"; | ||
| import "@nomicfoundation/hardhat-verify"; | ||
| import "hardhat-deploy"; | ||
| import "hardhat-deploy-ethers"; | ||
| import { task } from "hardhat/config"; | ||
| import generateTsAbis from "./scripts/generateTsAbis"; | ||
|
|
||
| // If not set, it uses the hardhat account 0 private key. | ||
| // You can generate a random account with `yarn generate` or `yarn account:import` to import your existing PK | ||
| const deployerPrivateKey = | ||
| process.env.__RUNTIME_DEPLOYER_PRIVATE_KEY ?? "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"; | ||
| // If not set, it uses our block explorers default API keys. | ||
| const etherscanApiKey = process.env.ETHERSCAN_V2_API_KEY || "DNXJA8RX2Q3VZ4URQIWP7Z68CJXQZSC6AW"; | ||
| import { type HardhatUserConfig, configVariable } from "hardhat/config"; | ||
| import type { HardhatRuntimeEnvironment } from "hardhat/types/hre"; | ||
| import type { TaskArguments } from "hardhat/types/tasks"; | ||
| import hardhatIgnitionViemPlugin from "@nomicfoundation/hardhat-ignition-viem"; | ||
| import { overrideTask } from "hardhat/config"; | ||
| import generateTsAbis from "./scripts/generateTsAbis.js"; | ||
| import hardhatToolboxViem from "@nomicfoundation/hardhat-toolbox-viem"; | ||
|
|
||
| // If not set, it uses ours Alchemy's default API key. | ||
| // You can get your own at https://dashboard.alchemyapi.io | ||
| const providerApiKey = process.env.ALCHEMY_API_KEY || "cR4WnXePioePZ5fFrnSiR"; | ||
| // TODO: Use configVariable | ||
| const providerApiKey = "cR4WnXePioePZ5fFrnSiR"; | ||
|
|
||
| const config: HardhatUserConfig = { | ||
| plugins: [hardhatIgnitionViemPlugin, hardhatToolboxViem], | ||
| solidity: { | ||
| compilers: [ | ||
| { | ||
|
|
@@ -38,116 +27,39 @@ const config: HardhatUserConfig = { | |
| }, | ||
| ], | ||
| }, | ||
| defaultNetwork: "localhost", | ||
| namedAccounts: { | ||
| deployer: { | ||
| // By default, it will take the first Hardhat account as the deployer | ||
| default: 0, | ||
| }, | ||
| }, | ||
| networks: { | ||
| // View the networks that are pre-configured. | ||
| // If the network you are looking for is not here you can add new network settings | ||
| hardhat: { | ||
| forking: { | ||
| url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`, | ||
| enabled: process.env.MAINNET_FORKING_ENABLED === "true", | ||
| }, | ||
| }, | ||
| mainnet: { | ||
| type: "http", | ||
| chainType: "l1", | ||
| url: "https://mainnet.rpc.buidlguidl.com", | ||
| accounts: [deployerPrivateKey], | ||
| accounts: [configVariable("DEPLOYER_PRIVATE_KEY")], | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd need to abstract this to the user for Also: for the keystore you need a 8 character password. Unless you use the |
||
| }, | ||
| sepolia: { | ||
| type: "http", | ||
| chainType: "l1", | ||
| url: `https://eth-sepolia.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| arbitrum: { | ||
| url: `https://arb-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| arbitrumSepolia: { | ||
| url: `https://arb-sepolia.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| optimism: { | ||
| url: `https://opt-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| optimismSepolia: { | ||
| url: `https://opt-sepolia.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygon: { | ||
| url: `https://polygon-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygonAmoy: { | ||
| url: `https://polygon-amoy.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygonZkEvm: { | ||
| url: `https://polygonzkevm-mainnet.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| polygonZkEvmCardona: { | ||
| url: `https://polygonzkevm-cardona.g.alchemy.com/v2/${providerApiKey}`, | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| gnosis: { | ||
| url: "https://rpc.gnosischain.com", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| chiado: { | ||
| url: "https://rpc.chiadochain.net", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| base: { | ||
| url: "https://mainnet.base.org", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| baseSepolia: { | ||
| url: "https://sepolia.base.org", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| scrollSepolia: { | ||
| url: "https://sepolia-rpc.scroll.io", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| scroll: { | ||
| url: "https://rpc.scroll.io", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| celo: { | ||
| url: "https://forno.celo.org", | ||
| accounts: [deployerPrivateKey], | ||
| }, | ||
| celoSepolia: { | ||
| url: "https://forno.celo-sepolia.celo-testnet.org/", | ||
| accounts: [deployerPrivateKey], | ||
| accounts: [configVariable("DEPLOYER_PRIVATE_KEY")], | ||
| }, | ||
| }, | ||
| // Configuration for harhdat-verify plugin | ||
| etherscan: { | ||
| apiKey: `${etherscanApiKey}`, | ||
| }, | ||
| // Configuration for etherscan-verify from hardhat-deploy plugin | ||
| verify: { | ||
| etherscan: { | ||
| apiKey: `${etherscanApiKey}`, | ||
| }, | ||
| }, | ||
| sourcify: { | ||
| enabled: false, | ||
| }, | ||
| }; | ||
| tasks: [ | ||
| overrideTask(["ignition", "deploy"]) | ||
| .setAction(async () => ({ | ||
| default: async ( | ||
| taskArgs: TaskArguments, | ||
| hre: HardhatRuntimeEnvironment, | ||
| runSuper: (args: TaskArguments) => Promise<any>, | ||
| ) => { | ||
| // Run the original ignition deploy task | ||
| await runSuper(taskArgs); | ||
|
|
||
| // Extend the deploy task | ||
| task("deploy").setAction(async (args, hre, runSuper) => { | ||
| // Run the original deploy task | ||
| await runSuper(args); | ||
| // Force run the generateTsAbis script | ||
| await generateTsAbis(hre); | ||
| }); | ||
| // Generate TypeScript ABIs after successful deployment | ||
| console.log("\n🔄 Generating TypeScript ABIs..."); | ||
| await generateTsAbis(); | ||
| console.log("✅ TypeScript ABIs generated successfully!\n"); | ||
| }, | ||
| })) | ||
| .build(), | ||
| ], | ||
| }; | ||
|
|
||
| export default config; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saving this for easier access :D