Lesson 7 problems with deploying on testnet #1401
-
Hi everyone, I can't get around this issue:
This is my code, I'm going to upload "FundMe.sol" and "01-deploy-fund-me.js" since I think these two bad boys are involved. FundMe.sol: // SPDX-License-Identifier:MIT
pragma solidity ^0.8.0;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "./PriceConverter.sol";
error NotOwner();
contract FundMe {
using PriceConverter for uint256;
address public immutable i_owner;
uint256 public constant MINIMUM_USD = 50 * 10**18;
address[] public funders;
mapping(address => uint256) public addressToAmountFunded;
AggregatorV3Interface public priceFeed;
constructor(address priceFeedAddress) {
i_owner = msg.sender;
priceFeed = AggregatorV3Interface(priceFeedAddress);
}
modifier onlyOwner() {
if (msg.sender != i_owner) revert NotOwner();
_;
}
function fund() public payable {
require(
msg.value.getConversionRate(priceFeed) >= MINIMUM_USD,
"Please, forward more funds"
);
funders.push(address(msg.sender));
addressToAmountFunded[msg.sender] += msg.value;
}
function wthdraw() public payable onlyOwner {
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
(bool callSuccess, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(callSuccess, "Call failed!");
}
fallback() external payable {
fund();
}
receive() external payable {
fund();
}
} 01-deploy-fund-me.js: const {
networkConfig,
developmentChains,
} = require("../helper-hardhat-config");
const { network } = require("hardhat");
const { verify } = require("../utils/verify");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let ethUsdPriceFeedAddress;
if (developmentChains.includes(network.name)) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator");
ethUsdPriceFeedAddress = ethUsdAggregator.address;
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
}
log(
"-------------------------------------------------------------------------"
);
log("Deploying FundMe and waiting for blocks confirmation...");
//const args = [ethUsdPriceFeedAddress];
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress],
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
});
log(`FundMe address: ${fundMe.address}`);
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, ethUsdPriceFeedAddress);
}
log(
"----------------------------------------------------------------------------"
);
};
module.exports.tags = ["all", "fundme"];
Thankyou in advance for your time, have a great day y'all :)
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 9 replies
-
make sure ethUsdPriceFeedAddress is not undifinded when you deploy on rinkeby |
Beta Was this translation helpful? Give feedback.
-
@pietrociarmatori Push to GitHub and leave a link here. |
Beta Was this translation helpful? Give feedback.
-
Make a repo and reply with the link. |
Beta Was this translation helpful? Give feedback.
-
@pietrociarmatori as @linuxsirn mentioned, you need to make sure that
|
Beta Was this translation helpful? Give feedback.
-
I ran into the same error. The problem is probably in the await run("verify:verify", {
address: contractAddress,
constructorArguments: args, // changed constructorArgs to constructorArguments
}) Try and see if it might work. Notify us if it ends up working. |
Beta Was this translation helpful? Give feedback.
-
As for me the problem was with verify.js Instead of constructorArgument write constructorArguments and it should work fine.
|
Beta Was this translation helpful? Give feedback.
I ran into the same error. The problem is probably in the
verify.js
file. I fixed mine by changingconstructorArg
toconstructorArguments
in myverify()
function. Because it seems that the function wasn't passing theethUsdPriceFeedAddress
argument to the constructor atFundMe.sol
Try and see if it might work. Notify us if it ends up working.