You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SPDX-License-Identifier: MITpragma solidity^0.8.8;
import"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import"./PriceConverter.sol";
// 812,034// 839,113error NotOwner();
contractFundMe {
using PriceConverterforuint256;
mapping(address=>uint256) public addressToAmountFunded;
address[] public funders;
// Could we make this constant? /* hint]: no! We should make it immutable! */addresspublicimmutable i_owner;
uint256public constant MINIMUM_USD =50*10**18;
constructor() {
i_owner =msg.sender;
}
function fund() publicpayable {
require(msg.value.getConversionRate() >= MINIMUM_USD, "You need to spend more ETH!");
// require(PriceConverter.getConversionRate(msg.value) >= MINIMUM_USD, "You need to spend more ETH!");
addressToAmountFunded[msg.sender] +=msg.value;
funders.push(msg.sender);
}
function getVersion() publicviewreturns (uint256){
// ETH/USD price feed address of Sepolia Network.
AggregatorV3Interface priceFeed =AggregatorV3Interface(0x694AA1769357215DE4FAC081bf1f309aDC325306);
return priceFeed.version();
}
function withdraw() public onlyOwner {
for (uint256 funderIndex=0; funderIndex < funders.length; funderIndex++){
address funder = funders[funderIndex];
addressToAmountFunded[funder] =0;
}
funders =newaddress[](0);
// // transfer// payable(msg.sender).transfer(address(this).balance);// // send// bool sendSuccess = payable(msg.sender).send(address(this).balance);// require(sendSuccess, "Send failed");// call// It's attempting to send the entire balance of the contract to the owner.
(boolcallSuccess, ) =payable(msg.sender).call{value: address(this).balance}("");
require(callSuccess, "Call failed");
}
modifier onlyOwner {
if(msg.sender!= i_owner){
revertNotOwner();
}
//require(msg.sender == i_owner, "Sender is not the owner!");_;
}
receive() externalpayable {
fund();
}
fallback() externalpayable{
fund();
}
//What happens if someone sends this contract ETH without calling the fund function
}
Hi, I'm having trouble with remix and an error, can someone help me?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I'm having trouble with remix and an error, can someone help me?
Beta Was this translation helpful? Give feedback.
All reactions