通过智能合约将ETH转移到其他帐户?
在以下代码中,将以WEI的形式转移eTH,但我希望金额以醚的形式转移,我该怎么做?
function (uint amount) public payable {
someaddress.transfer(amount);
}
In the below code eth will be transferred in the form of Wei by default, but I want the amount will transfer in the form of Ether, how can I do that?
function (uint amount) public payable {
someaddress.transfer(amount);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WEI是以太的最小单位,特别是1 eth == 1,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000亿。
Transfer()
函数始终接受WEI中的金额。因此,如果您只想将1
作为输入参数,这意味着要发送1个完整的ETH,则可以将值乘以1E18有效地将ETH转换为WEI。注意:还有全局单元,但在当前的固定版本(0.8)中,它只能与数字文字结合使用,而不是与变量一起使用。
Wei is the smallest unit of Ether, specifically 1 ETH == 1,000,000,000,000,000,000 (or 1e18) wei.
The
transfer()
function always accepts the amount in wei. So if you want to pass just1
as the input param, meaning that you want to send 1 full ETH, you can multiply the value by 1e18 effectively converting ETH to wei.Note: There's also the ether global unit, but in the current Solidity version (0.8), this can be used only in combination with number literals - not with variables.