function getConversionRate is returning zero #268
Answered
by
tuhindasv0
tuhindasv0
asked this question in
Q&A
-
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
uint256 public minimumAmount= 10;
function fund() public payable {
require(getConversionRate(msg.value)>=minimumAmount,"Please send atleast 1 Eth");
}
function getPrice() public view returns (uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
(, int256 answer, , , ) = priceFeed.latestRoundData();
// ETH/USD rate in 18 digit
return uint256(answer * 10000000000);
}
function getConversionRate(uint256 ethAmount) public view returns (uint256) {
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1e18;
return ethAmountInUsd;
}
// function withdraw() public {
// }
} Can anyone help me here, my getConversionRate function returning 'ZERO' everytime. |
Beta Was this translation helpful? Give feedback.
Answered by
tuhindasv0
Jun 11, 2022
Replies: 1 comment 2 replies
-
fixed |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tuhindasv0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed