簡體   English   中英

在 Remix 中部署 solidity 合約時如何修復/調試錯誤(無效的 arrayify 值)

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

問題

我正在嘗試通過Remix部署智能合約。 不幸的是,它失敗了,並顯示了一條非常無用的錯誤消息。

錯誤信息

創建 MyContract 出錯:錯誤編碼 arguments:錯誤:無效的 arrayify 值 (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從抽象合同和常規合同繼承。 有沒有辦法查看錯誤或來源的位置,或者是否有可能對其進行調試?

構造函數將字節數組作為參數。

當您傳遞一個空值時,它會導致您的問題中提到的錯誤消息。 這是因為您有效地傳遞了“無價值” - 而不是“空字節數組”。

空值

創建 MyContract 錯誤:編碼 arguments 錯誤:錯誤:無效的數組化值(argument="value",value="",code=INVALID_ARGUMENT,version=bytes/5.5.0)

如果要傳遞一個空字節數組,則需要使用[]0x表達式(這兩個選項都有效):

空數組

空數組

它可以輸入“[]”或“0x”,我理解的“數據”應該具有類似“[xxx]”的格式,我建議持有者可以更新描述以澄清它。 謝謝 Petr 回答了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM