如何修复“部署时迁移遇到无效操作码”问题Solidity 中的错误?
P粉523625080
P粉523625080 2024-03-27 00:03:27
[JavaScript讨论组]

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

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

我的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;
      }
    }

我的松露 config.js 文件

    const path = require("path");

    module.exports = {
      // See 
      // to customize your Truffle configuration!
      contracts_build_directory: path.join(__dirname, "/build"),
  
   
      networks: {
        development: {
        host: "127.0.0.1",
      port: 8545,
      network_id: "*" //Match any network id
     }
    },
    
    plugins: ["truffle-contract-size"],
    compilers: {
    solc: {
      version: "^0.8.0"
    }
    },
    solidity: {
    version: "0.8.3",
    settings: {
      optimizer: {
        enabled: true,
        runs: 1000,
      },
    },
  },
   };

P粉523625080
P粉523625080

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号