Lesson 4 - Gas Estimation Failed - The transaction execution will likely fail. #849
-
Hi all, I am trying to fund the fund me contract, but it is costing too much gas for the contract to run. I'm not sure what is wrong with my code, can someone take a look? Thank you so much. This course is amazing. pragma solidity ^0.8.8;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
uint256 public minimumUsd = 50 * 1e18;
function fund() public payable{
require(getConversionRate(msg.value) >= minimumUsd, "Didn't send enough");
}
function getPrice() public view returns (uint256){
// ABI (list of functions and interactions, here are the ones you can call)
// Inteface === ABI
// Address 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
(,int256 price,,,) = priceFeed.latestRoundData();
return uint256(price* 1e10);
}
function getVersion() public view returns (uint256){
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
return priceFeed.version();
}
function getConversionRate(uint256 ethAmount) public view returns (uint256) {
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1e18;
return ethAmountInUsd;
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The exact error is: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? It doesn't show a message below after stating that :/ |
Beta Was this translation helpful? Give feedback.
-
@Nick-qsv If you running on a Rinkeby network, then you are using a wrong Aggregator address This is address for Rinkeby: |
Beta Was this translation helpful? Give feedback.
@Nick-qsv If you running on a Rinkeby network, then you are using a wrong Aggregator address
This is address for Rinkeby:
0x8A753747A1Fa494EC906cE90E9f37563A8AF630e