0

命令“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";
  }
}
4

1 回答 1

0

解决方案:我删除了我的项目文件夹并重建了它。这解决了它。不确定到底是什么问题。

于 2022-02-08T16:57:41.393 回答