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:
I am just following the exact code description from "Mastering Ethereum" book, here the reason I am using quote marks:
Why it?
如果您在引号编译器中传递值,请尝试输入不带引号的值。bcoz 或 EVM 识别出它是一个字符串。输入的数字不带引号。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.