簡體   English   中英

區塊鏈松露遷移錯誤

[英]Blockchain truffle Migration Error

truffle migrate 使用網絡“開發”。

Running migration: 1_initial_migration.js   Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful
transactions manually. Error: Migrations contract constructor expected
1 arguments, received 0
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:390:1

我的 Solidity 文件(Migration.sol)

pragma solidity ^0.4.17;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

  modifier restricted() {
    if (msg.sender == owner) _;
  }

  constructor(Migrations) public {
    owner = msg.sender;
  }

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;
  }

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}

我的遷移文件 1_initial_migration.js

var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

松露版本松露 v4.1.11(核心:4.1.11)Solidity v0.4.24(solc-js)

移除構造函數參數“Migrations”,該參數在任何地方都不使用。 當我刪除“遷移”參數時它正在工作。 使用如下:

constructor() public {
    owner = msg.sender;
  }

如果在 Ganache 上更改為 Instabul 或更改您所在的 CHAIN

暫無
暫無

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

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