首页 > 解决方案 > Solidity:“错误:无效的数值”,即使使用引号内的数值,为什么?

问题描述

我正在通过 Mastering Ethereum 这本书学习,然后我正在做一个创建合约的练习,在那里接收以太币并提取它。但是我收到一个错误,我不知道为什么,考虑到我正在遵循所有步骤。

编码:


// 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);
    }
}

将“100000000000000000”放在提现功能字段后的错误:

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

这是我的屏幕:

桌面图像

我只是遵循“掌握以太坊”一书中的确切代码描述,这就是我使用引号的原因:

书籍图片

为什么呢?

标签: javascriptblockchainethereumsolidity

解决方案


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


推荐阅读