Done auto select price feed based on network & verify on testnet

This commit is contained in:
2024-08-05 21:30:14 +08:00
parent 39c2dd760b
commit ee8912613c
12 changed files with 331 additions and 35 deletions
+1
View File
@@ -6,6 +6,7 @@ const {
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config");
const { verify } = require("../utils/verify");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
+14 -2
View File
@@ -8,6 +8,7 @@ const {
const helperConfig = require("../helper-hardhat-config");
const networkConfig = helperConfig.networkConfig;
*/
const { verify } = require("../utils/verify");
/*
// main function that auto run via hardhat deploy
@@ -19,6 +20,14 @@ function deployFunc() {
module.exports.default = deployFunc;
*/
/*
module.exports = async () => {
let contractAddress = "0x3a827C119e1D746bb3C7bcbbf95c55246C8CcBdd";
let priceFeedAddress = "0x694AA1769357215DE4FAC081bf1f309aDC325306";
await verify(contractAddress, [priceFeedAddress]);
};
*/
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts(); // Take from hardhat.config.js namedAccounts
@@ -46,20 +55,23 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
log("----------------------------------------------------");
log("Deploying FundMe Contract and waiting for confirmations...");
const argsPriceFeed = [ethUsdPriceFeedAddress];
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress],
args: argsPriceFeed,
log: true,
// we need to wait if on a live network so we can verify properly
waitConfirmations: network.config.blockConfirmations || 1,
});
log(`FundMe deployed at ${fundMe.address}`);
// If on testnet, then verify smart contract
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, [ethUsdPriceFeedAddress]);
// Verify Code
await verify(fundMe.address, argsPriceFeed);
}
};