Márcio
Márcio

Reputation: 181

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:

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?

Upvotes: 2

Views: 1599

Answers (1)

Dhiraj Bhor
Dhiraj Bhor

Reputation: 21

Try to entering values without quotes.bcoz if you pass the value within quotes copiler or EVM recognises it is an string.The Numbers are entered without quotes.

Upvotes: 1

Related Questions