簡體   English   中英

Solidity:“錯誤:無效的數值”,即使在引號內使用數值,為什么?

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

我正在學習《掌握以太坊》這本書,然后我正在做一個創建合約的練習,在那里接收以太幣並撤回它。 但是我收到一個錯誤,我不知道為什么,考慮到我正在遵循所有步驟。

編碼:


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

這是我的屏幕:

桌面圖像

我只是遵循“掌握以太坊”一書中的確切代碼描述,這里是我使用引號的原因:

書本形象

為什么呢?

如果您在引號編譯器中傳遞值,請嘗試輸入不帶引號的值。bcoz 或 EVM 識別出它是一個字符串。輸入的數字不帶引號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM