简体   繁体   English

Solidity:“错误:无效的数值”,即使在引号内使用数值,为什么?

[英]Solidity: “Error: invalid number value”, even when using the number value within quote marks, why?

I am studying by Mastering Ethereum book, then I am doing an exercise that creates a contract, receive ether there and withdraw it.我正在学习《掌握以太坊》这本书,然后我正在做一个创建合约的练习,在那里接收以太币并撤回它。 But I am getting an error, I don't know why, considering I am following all the steps.但是我收到一个错误,我不知道为什么,考虑到我正在遵循所有步骤。

The code:编码:


// Version of Solidity compiler this program was written for
pragma solidity ^0.6.0;

// Our first contract is a faucet!
contract Faucet {
    // Accept any incoming amount
    receive () external payable {}
    
    // Give out ether to anyone who asks
    function withdraw(uint withdraw_amount) public {

        // Limit withdrawal amount
        require(withdraw_amount <= 100000000000000000);

        // Send the amount to the address that requested it
        msg.sender.transfer(withdraw_amount);
    }
}

The error after put “100000000000000000” on the withdraw function field:在提款函数字段上放“100000000000000000”后的错误:

transact to Faucet.withdraw errored: Error encoding arguments: Error: invalid number value (arg="", coderType="uint256", value="1.0000000000000000", version=4.0.47)

Here my screen:这是我的屏幕:

desktop image桌面图像

I am just following the exact code description from "Mastering Ethereum" book, here the reason I am using quote marks:我只是遵循“掌握以太坊”一书中的确切代码描述,这里是我使用引号的原因:

book image书本形象

Why it?为什么呢?

如果您在引号编译器中传递值,请尝试输入不带引号的值。bcoz 或 EVM 识别出它是一个字符串。输入的数字不带引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM