簡體   English   中英

truffle migrate 只遷移第一個合同,而不是第二個

[英]truffle migrate only migrating first contract, not the second

命令“truffle migrate”工作正常(沒有錯誤)但只遷移“Migrations.sol”。 它甚至不嘗試使用 2_deploy_contracts.js 進行遷移

1_initial_migration.js:

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

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

遷移.sol:

enter code herepragma solidity ^0.4.25;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

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

  function Migration() public {
    owner = msg.sender;
  }

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

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

2_deploy_contracts.js:

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

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

選舉.sol:

pragma solidity ^0.4.25;

contract Election {
  // Store candidate
  // Read candidate
  string public candidate;

  // Constructor
  // Our constructor will be run when the contract gets deployed, so must be public
  constructor() public{
      candidate = "Candidate 1";
  }
}

解決方案:我刪除了我的項目文件夾並重建了它。 這修復了它。 不確定到底是什么問題。

暫無
暫無

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

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