[英]address.call.value(amount)( ) method is not working with me
I've written a very simple method in solidity to send Ethereum to account but unfortunately it is not working我已经写了一个非常简单的方法来将以太坊发送到账户,但不幸的是它不起作用
(ALREADY TRIED SEND AND TRANSFER METHOD) (已尝试发送和转移方法)
function sendByCallValue(address payable _receiver, uint _amount) public payable {
(bool success, ) = _receiver.call{value:_amount}("");
require(success, "Transfer failed.");
}
I'm calling this function from REMIX IDE by passing an address and amount but it is throwing error.我通过传递地址和数量从 REMIX IDE 调用此函数,但它抛出错误。
In pic you will find this:在图片中你会发现:
to : NftStaker.sendByCallValue(address,uint256) 0xEf9f1ACE83dfbB8f559Da621f4aEA72C6EB10eBf
which I think should be like this我认为应该是这样的
to : 0xEf9f1ACE83dfbB8f559Da621f4aEA72C6EB10eBf
I'm not sure which thing is throwing error.我不确定哪个东西会引发错误。
The transaction output shows that you're passing 0 wei along with the transaction, and trying to send 10 wei from the contract address.交易输出显示你在交易中传递了 0 wei,并尝试从合约地址发送 10 wei。
It doesn't show how much the contract owns, but assuming it's less than 10 wei, the transaction fails because the .call()
is trying to send from the contract more than it owns.它没有显示合约拥有多少,但假设它小于 10 wei,则交易失败,因为.call()
试图从合约中发送比它拥有的更多的东西。
You can specify the value
to send along with the transaction in the "Deploy & run transactions" of the Remix IDE.您可以在 Remix IDE 的“部署和运行事务”中指定要与事务一起发送的value
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.