javascript - 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)
这是我的屏幕:
我只是遵循“掌握以太坊”一书中的确切代码描述,这就是我使用引号的原因:
为什么呢?
解决方案
如果您在引号编译器中传递值或 EVM 识别它是一个字符串,请尝试输入不带引号的值。bcoz 输入的数字不带引号。
推荐阅读
- javascript - 如何使用哈希表来计算对象的出现次数?
- javascript - 如何防止侧边栏在页面加载时显示瞬间?
- gitlab - 如何在 gitlab“阶段”中定义规则,以便无需为作业定义单独的规则
- powerquery - Power BI M 语言 - 将标签列表转换为多行
- python - 如何编写计算连接表示的字符串数的方法
- typescript - AWS CDK CfnMaintenanceWindowTask/taskInvocationParameters - TypeScript
- asp.net-core - 将自定义 json 文件添加到 IConfigrutaion 时,我不能再使用 SeBasePath?
- mysql - DECIMAL() 类型上的动态 ROUND() 不会截断尾随小数位 - MySQL
- json - 通过 Google Appscript 启动 UIPath 作业
- r - 如何从我的数据框在 R 闪亮上带来正确的结果?