简体   繁体   English

address.call.value(amount)() 方法不适用于我

[英]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.

相关问题 如何获得发送到以太坊地址的总金额 - How to get the total amount sent to an Etherum address 错误:无效地址(arg="", coderType="address", value=[0]) - ERROR: invalid address (arg="", coderType="address", value=[0]) 如何获取anchor solana中给定令牌地址的数量? - how to get the the amount of the given token address in anchor solana? 即使输入正确的bytes32值和地址值也是如此。 Setaddress功能不起作用 - Even after entering proper bytes32 value and address value. Setaddress function is not working 使用地址和金额打开比特币钱包的正确链接是什么? - What is the correct link to open bitcoin wallets with address and amount? 通过连接安全帽(ethers)中的合约地址调用智能合约 function - Call smart contract function by connecting contract address in hardhat (ethers) 如何使用 solidity 调用 function 从合同中发送固定数量的以太币? - How to send fixed amount of ether from contract using call function in solidity? 如何获取 solana 上的交易金额或价值? - How to Get Transaction Amount Or Value on solana? 未找到方法:erisdb.call - Method not found: erisdb.call EthereumJS 库没有为我提供正确的地址(缺少 0x) - EthereumJS library not providing me with correct address (missing 0x)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM