Warm tip: This article is reproduced from serverfault.com, please click

Truffle migrate command ReferenceError: Migrations not defined?

发布于 2020-12-09 17:57:04

I'm trying to migrate a test smart contract and when I type the command I'm getting a "ReferenceError: Migrations is not defined" NOTE: The error is for my second file, the first one is migrated without any problem. Here's a screenshot of the full error message:

CMD ERROR

Files in use:

files

I'll leave the code of each file below:

Ethswap.sol:

pragma solidity ^0.5.0;

contract EthSwap {
  string public name = "EthSwap Instant Exchange";
}

2_deploy_contracts.js:

const EthSwap = artifacts.require("EthSwap");

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

1_initial_migration.js:

const Migrations = artifacts.require("Migrations");

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

I'd deeply appreciate a solution!

Questioner
Leon
Viewed
0
Ming 2020-12-10 09:19:04

In your 2_deploy_contract.js, Migration is not declared.

Instead of

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

Change it to

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