【问题标题】:How to fix / debug errors (invalid arrayify value) when deploying a solidity contract in Remix在 Remix 中部署 Solidity 合约时如何修复/调试错误(无效的数组化值)
【发布时间】:2022-08-15 16:12:54
【问题描述】:

问题

我正在尝试通过Remix 部署智能合约。不幸的是,它失败并显示非常无用的错误消息。

错误信息

创建 MyContract 错误:错误编码参数:错误:无效的数组化值(argument=\"value\",value=\"\",code=INVALID_ARGUMENT,version=bytes/5.5.0)

代码

这是contract 使用的构造函数:

struct RRSet {
    uint32 inception;
    uint32 expiration;
    bytes20 hash;
}

constructor(bytes memory _anchors) {
    // Insert the \'trust anchors\' - the key hashes that start the chain
    // of trust for all other records.
    anchors = _anchors;
    rrsets[keccak256(hex\"00\")][DNSTYPE_DS] = RRSet({
        inception: uint32(0),
        expiration: uint32(3767581600), // May 22 2089 - the latest date we can encode as of writing this
        hash: bytes20(keccak256(anchors))
    });
    emit RRSetUpdated(hex\"00\", anchors);
}

一些想法

我的合约使用is 从抽象合约以及常规合约继承。有没有办法查看错误或源自何处,或者是否有可能对其进行调试?

  • 似乎有一个构造函数需要一些参数,但您传递的是空值或格式不正确的值。您可以分享构造函数代码以及您传递给它的内容吗?
  • 我用构造函数更新了代码

标签: blockchain ethereum solidity smartcontracts remix


【解决方案1】:

构造函数将字节数组作为参数。

当您传递一个空值时,它会导致您的问题中提到的错误消息。这是因为您有效地传递了“无价值” - 而不是“空字节数组”。

创建 MyContract 出错:错误编码参数:错误:无效的数组化值(argument="value",value="",code=INVALID_ARGUMENT,version=bytes/5.5.0)

如果要传递一个空字节数组,则需要使用[] 或0x 表达式(这两个选项都有效):

【讨论】:

    【解决方案2】:

    它可以输入“[]”或“0x”,我理解的“数据”应该具有类似“[xxx]”的格式,我建议持有者可以更新描述以澄清它。 谢谢 Petr 回答了这个问题。

    【讨论】:

      猜你喜欢
      • 2019-07-23
      • 2021-07-24
      • 1970-01-01
      • 2021-07-25
      • 2021-07-05
      • 2020-08-28
      • 2022-07-01
      • 2022-08-05
      • 2022-01-21
      相关资源
      最近更新 更多