transact to FundMe.withdraw errored: Invalid parameters: must provide an Ethereum address. #918
Replies: 5 comments 10 replies
-
It is difficult to reconstruct what might have gone wrong without context. Don't be shy to post your source code here, no paper to waste ;-) |
Beta Was this translation helpful? Give feedback.
-
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
mapping(address => uint256) public AddressToAmount;
address[] public funders;
//address of the owner (who deployed the contract)
address public owner;
constructor() {
owner = msg.sender;
}
function Fund() public payable {
uint256 minimumUSD = 50 * 10 ** 8;
require(getConversionRate(msg.value) >= minimumUSD, "You need to spend more ETH!");
AddressToAmount[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getPrice() public view returns(uint256) {
AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
(,int256 answer,,,) = priceFeed.latestRoundData();
return uint256(answer);
}
function getConversionRate (uint256 WeiAmount) public view returns(uint256) {
uint256 EthPrice = getPrice();
uint256 AmountInUsd = (WeiAmount * EthPrice) / 1000000000000000000;
return AmountInUsd;
}
modifier onlyOwner {
//is the message sender owner of the contract?
require(msg.sender == owner);
_;
}
function withdraw () public onlyOwner payable {
payable(msg.sender).transfer(address(this).balance);
for (uint256 funderIndex=0; funderIndex < funders.length; funderIndex++){
address funder = funders[funderIndex];
AddressToAmount[funder] = 0;
}
//funders array will be initialized to 0
funders = new address[](0);
}
} |
Beta Was this translation helpful? Give feedback.
-
OK, the source code is identical to https://github.com/PatrickAlphaC/fund_me/blob/main/FundMe.sol |
Beta Was this translation helpful? Give feedback.
-
Please check, if your second metamask account is connected. Here an example of a not connected account: |
Beta Was this translation helpful? Give feedback.
-
As a workaround try removing the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm getting this error when im trying to fund the contract from another account. Works fine with owner account but not the second one.
Beta Was this translation helpful? Give feedback.
All reactions