简体   繁体   English

在 Remix 中部署 solidity 合约时如何修复/调试错误(无效的 arrayify 值)

[英]How to fix / debug errors (invalid arrayify value) when deploying a solidity contract in Remix

Problem问题

I am trying to deploy a smart contract via Remix .我正在尝试通过Remix部署智能合约。 Unfortunately, it fails with a very unhelpful error message.不幸的是,它失败了,并显示了一条非常无用的错误消息。

Error Message错误信息

creation of MyContract errored: Error encoding arguments: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.5.0)创建 MyContract 出错:错误编码 arguments:错误:无效的 arrayify 值 (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.5.0)

Code代码

Here is the constructor the contract uses:这是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);
}

Some thoughts一些想法

My contract uses is to inherit from an abstract contract as wells as from a regular contract.我的合同使用is从抽象合同和常规合同继承。 Is there a way to see where to error or originates from or is there a possiblity to debug it?有没有办法查看错误或来源的位置,或者是否有可能对其进行调试?

The constructor takes a byte array as an argument.构造函数将字节数组作为参数。

When you pass an empty value, it results in the error message mentioned in your question.当您传递一个空值时,它会导致您的问题中提到的错误消息。 It's because you're effectively passing "no value" - not "empty byte array".这是因为您有效地传递了“无价值” - 而不是“空字节数组”。

空值

creation of MyContract errored: Error encoding arguments: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.5.0)创建 MyContract 错误:编码 arguments 错误:错误:无效的数组化值(argument="value",value="",code=INVALID_ARGUMENT,version=bytes/5.5.0)

If you want to pass an empty byte array, you need to use the [] or 0x expression (both options work):如果要传递一个空字节数组,则需要使用[]0x表达式(这两个选项都有效):

空数组

空数组

It works to input "[]" or "0x", what I understand the "data" which should has a format like "[xxx]", I suggest holders can update a description to clarify it.它可以输入“[]”或“0x”,我理解的“数据”应该具有类似“[xxx]”的格式,我建议持有者可以更新描述以澄清它。 Thank you Petr answers this question.谢谢 Petr 回答了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 remix solidity contract如何将多个参数传递给create按钮 - remix solidity contract how to pass multiple arguments into the create button 主网在Remix Solidity智能合约中将地址数组部署为构造函数参数不起作用 - Mainnet deploying array of addresses as constructor parameter in Remix Solidity smart contract does not work 如何在合约中设置 ETH 的接收者,以在 remix IDE 中使用solidity usign call() 从一个地址向另一个地址发送ETH - How to set the receiver of ETH in a contract to send ETH from one address to another with solidity usign call() in remix IDE 在 Solidity 中调用 contract.transfer 方法时如何调试运行时错误? - How can I debug the runtime error when call contract.transfer method in Solidity? 当我传递智能合约函数的数组时,它给我的错误是:“实体函数的参数数量无效”,为什么? - When I am passing array of my smart contract function it is giving me errors saying “invalid number of arguments to solidity function” Why? 通过 Angular 前端部署 Solidity 智能合约 - Deploying Solidity Smart Contract via Angular Frontend 在 Solidity 中部署智能合约后调用智能合约的 function - Call function of smart contract after deploying smart contract in Solidity 如何解决solidity Remix中的类型错误 - how to solve type error in solidity Remix Solidity - 部署合约时,我收到“SyntaxError: Unexpected token o in JSON at position 1” - Solidity - When deploying the contract I get "SyntaxError: Unexpected token o in JSON at position 1" 如何测试 Solidity 应付合同 - How to test a Solidity payable contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM