小编kar*_*mte的帖子

如何修复 Solidity 中的“部署时迁移遇到无效操作码”错误?

“迁移”在部署时遇到无效的操作码。尝试:

  • 验证您的构造函数参数是否满足所有断言条件。
  • 验证构造函数代码不会越界访问数组。
  • 将原因字符串添加到断言语句中。出现这个错误如何解决

我的migration.sol代码

    // SPDX-License-Identifier: UNLICENSED

    //the version of solidity that is compatible

    pragma solidity ^0.8.0;
    contract Migrations {
      address public owner = msg.sender;
      uint public last_completed_migration;

      modifier restricted() {
        require(
          msg.sender == owner,
          "This function is restricted to the contract's owner"
        );
        _;
      }

      function setCompleted(uint completed) public restricted {
        last_completed_migration = completed;
      }
    }
Run Code Online (Sandbox Code Playgroud)

我的松露 config.js 文件

    // SPDX-License-Identifier: UNLICENSED

    //the version of solidity that is compatible

    pragma solidity ^0.8.0;
    contract Migrations {
      address public owner …
Run Code Online (Sandbox Code Playgroud)

javascript blockchain ethereum solidity

2
推荐指数
1
解决办法
1339
查看次数

标签 统计

blockchain ×1

ethereum ×1

javascript ×1

solidity ×1