可靠智能合同代码是:
function recharge() public payable {
address payable _wallet=address(this);
_wallet.transfer(msg.value);
}javascript代码是:
this.state.contract.methods.recharge().send({from:this.state.owner,value: Web3.utils.toWei(this.state.Recharge, 'ether')})*合同和所有者存储在状态变量中,但这会在处理事务时出现错误Err0r:VM异常: gives
发布于 2020-09-01 07:31:35
如果您只是希望将以太发送到合同,则没有必要显式地将以太发送到address(this)。使用空函数将有效:
function recharge() public payable {
// noop
}您还可以使用receive函数使您的合同始终接受以太事务,而无需调用该函数:
receive () external payable {
// noop
}https://ethereum.stackexchange.com/questions/87091
复制相似问题