Problem with min_usd calculations #2442
Answered
by
alymurtazamemon
Agastya221
asked this question in
Q&A
-
MINIMUM_USD = 50 * 10 ** 18 = 50 Eth Here's my code if this is happening because of any mistake or error please correct it 🙏 // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract tryit {
uint256 public miniusd = 50 * 1e18;
address payable owner;
address[] public Fundaddress;
AggregatorV3Interface internal priceFeed;
constructor (){
priceFeed = AggregatorV3Interface(0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e);
owner = payable(msg.sender);
}
function getprice() public view returns (uint256) {
(
/*uint80 roundID*/,
int price,
/*uint startedAt*/,
/*uint timeStamp*/,
/*uint80 answeredInRound*/
) = priceFeed.latestRoundData();
return uint256(price * 1e18);
}
modifier onlyowner{
require(msg.sender == owner, "not");
_;
}
function addFund() public payable {
require(getconversion(msg.value) >= miniusd,"failed");
Fundaddress.push(msg.sender);
}
function widthdraw() public onlyowner {
// (bool callSuccess, ) = payable(msg.sender).call{value: address(this).balance}("");
// require(callSuccess, "Call failed");
(bool callSuccess,) = owner.call{value: address(this).balance}("");
require(callSuccess,"Not the owner");
}
function getconversion(uint256 ethAmount) public view returns(uint256) {
uint256 ethprice = getprice();
uint256 ethAmountInUsd = (ethprice * ethAmount) / 1e18;
return ethAmountInUsd;
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Sep 9, 2022
Replies: 1 comment 2 replies
-
@Agastya221 here -uint256(price * 1e18);
+uint256(price * 1e10); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Agastya221
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Agastya221 here