// SPDX-License-Identifier: MIT pragma solidity >=0.6.6 <0.9.0; import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; contract FundMe{ mapping(address => uint256) public addressToAmountFunded; address[] public funders; address public owner; constructor() public { owner = msg.sender; } function fund() public payable { // 50$ uint256 minimumUSD = 50* 10**18; uint256 actualUSD = getConversionRate(msg.value); require (actualUSD > minimumUSD, "not enough ETH!"); addressToAmountFunded[msg.sender] += msg.value; funders.push(msg.sender); } function getVersion() public view returns(uint256){ // that says we have a contract that is located at this address and has the functiones deifned in the interface AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e); return priceFeed.version(); } function getDecimals() public view returns(uint8){ AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e); return priceFeed.decimals(); } function getPrice() public view returns(uint256){ AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e); (, //uint80 roundId, int256 answer , //uint256 startedAt, , //uint256 updatedAt, , //uint80 answeredInRound ) = priceFeed.latestRoundData(); return uint256(answer * 1000000000); } function getConversionRate(uint256 ethAmount) public view returns(uint256){ // meins return getPrice() * addressToAmountFunded[msg.sender]; uint256 ethPrice = getPrice(); uint256 ethAmountInUSD = (ethPrice * ethAmount) / 100000000000000000; return ethAmountInUSD; } modifier onlyOwner { // only the owner require(msg.sender == owner, "not allowed"); _; } function withdraw() payable onlyOwner public { msg.sender.transfer(address(this).balance); for (uint256 funderIndex=0; funderIndex