i cannot do transaction to send out money from smart contract to other account ? Anyone know why?? here the error message code: -32602
message: "Invalid parameters: must provide an Ethereum address."
Jan 16, 2021, 4:42 PM
my accounts is connecting with metamask
i have tried before it still happen
function withdraw(uint256 _amount) public payable {
//withdraw the money to who out the money
msg.sender.transfer(_amount);
//function for any miss dangeroius contract
if(_amount >=limit){
Info memory newInfo = Info({
owner: msg.sender,
amount: _amount
});
infos.push(newInfo);
}
}
//withdraw the money to who out the money
msg.sender.transfer(_amount);
//function for any miss dangeroius contract
if(_amount >=limit){
Info memory newInfo = Info({
owner: msg.sender,
amount: _amount
});
infos.push(newInfo);
}
}
onWithdraw = async event => {
try {
event.preventDefault();
const fromAddress = "0x2B8e74e6a780922273F4F18cD9C90709896BC6ad";
const accounts = await web3.eth.getAccounts();
await bank.methods.withdraw(this.state.withdrawvalue).send({
from: fromAddress,
to: accounts[0],
value: web3.utils.toWei(this.state.withdrawvalue, "ether")
});
} catch (e) {
console.log(e);
}
};
try {
event.preventDefault();
const fromAddress = "0x2B8e74e6a780922273F4F18cD9C90709896BC6ad";
const accounts = await web3.eth.getAccounts();
await bank.methods.withdraw(this.state.withdrawvalue).send({
from: fromAddress,
to: accounts[0],
value: web3.utils.toWei(this.state.withdrawvalue, "ether")
});
} catch (e) {
console.log(e);
}
};
Jan 16, 2021, 4:49 PM
THIS works for me:
web3.eth.getAccounts(function (err, accounts) {
myAddr = accounts[0];
console.log(myAddr);
}
web3.eth.getAccounts(function (err, accounts) {
myAddr = accounts[0];
console.log(myAddr);
}
Jan 16, 2021, 5:15 PM