Skip to content

Instantly share code, notes, and snippets.

@Scofield-Idehen
Created August 1, 2022 16:10
Show Gist options
  • Save Scofield-Idehen/8aded325eb06bf598e2c2c31fb906e2a to your computer and use it in GitHub Desktop.
Save Scofield-Idehen/8aded325eb06bf598e2c2c31fb906e2a to your computer and use it in GitHub Desktop.
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract PriceOFETHTOUSD{
uint minimalValue = 50;
function PriceFeed() public payable{
msg.value > minimalValue;
}
function GetLastestPrice() public view returns (uint){
AggregatorV3Interface Price = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
(,int256 price,,,) = Price.latestRoundData();
return uint (price * 1e18);
}
function GetValueInDOllar(uint _ethAmount) public view returns(uint){
uint ValuePrice = GetLastestPrice();
uint AmountinDollars =(ValuePrice * _ethAmount) /1e18;
return AmountinDollars;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment