在 Remix 中部署 solidity 合约时如何修复/调试错误(无效的 arrayify 值)
How to fix / debug errors (invalid arrayify value) when deploying a solidity contract in Remix
问题
我正在尝试通过 Remix 部署智能合约。不幸的是,它失败了,并显示了一条非常无用的错误消息。
错误信息
creation of MyContract errored: Error encoding arguments: Error: invalid arrayify value (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
从抽象合约和常规合约继承。有没有办法查看错误或起源的位置,或者是否有可能对其进行调试?
构造函数将字节数组作为参数。
当您传递一个空值时,会导致出现您问题中提到的错误消息。这是因为您实际上传递的是“无值”——而不是“空字节数组”。
creation of MyContract errored: Error encoding arguments: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.5.0)
如果你想传递一个空字节数组,你需要使用[]
或0x
表达式(两个选项都有效):
问题
我正在尝试通过 Remix 部署智能合约。不幸的是,它失败了,并显示了一条非常无用的错误消息。
错误信息
creation of MyContract errored: Error encoding arguments: Error: invalid arrayify value (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
从抽象合约和常规合约继承。有没有办法查看错误或起源的位置,或者是否有可能对其进行调试?
构造函数将字节数组作为参数。
当您传递一个空值时,会导致出现您问题中提到的错误消息。这是因为您实际上传递的是“无值”——而不是“空字节数组”。
creation of MyContract errored: Error encoding arguments: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.5.0)
如果你想传递一个空字节数组,你需要使用[]
或0x
表达式(两个选项都有效):