I have started working with truffle since 4 months and I don't give importance to Migrations.sol, I thought it's just a "get started" contract. But when I removed it caused a problem.
can anyone explains the role of this contract?

  • 3
    this is a good reason I am not using truffle , it pollutes my testing environment, debug logs, and also spends unnecessary money on deployment. Not everybody can make a perfect product, it takes discipline and customer oriented mentality to be the first.
    – Nulik
    Aug 13, 2018 at 21:01

2 Answers 2


The Migrations contract keeps track of which migrations were done on the current network.

Inside the migrations folder, you'll see a file called 1_initial_migration.js The 1 in the filename is the reference number of a migration.

Once you've created a couple of contracts, and want to deploy them using truffle migrate, you can create another migration file called 2_name_of_migration.js. Once the migration is done, Truffle will store that 2 reference number in the Migrations contract

  • 1
    but in prod it will consume gas that I'm not supposed to pay it.
    – maroodb
    Aug 13, 2018 at 11:41
  • 2
    Yeah, correct. I'm not a fan of this system because of that
    – Henk
    Aug 13, 2018 at 11:47
  • So why this is necessary, can you turn it off? Nov 27, 2019 at 6:43

Good Answer from here:

The Migrations contract stores (in last_completed_migration) a number that corresponds to the last applied "migration" script, found in the migrations folder. Deploying this Migrations contract is always the first such step anyway. The numbering convention is x_script_name.js, with x starting at 1. Your real-meat contracts would typically come in scripts starting at 2_....

So, as this Migrations contract stores the number of the last deployment script applied, Truffle will not run those scripts again. On the other hand, in the future, your app may need to have a modified, or new, contract deployed. For that to happen, you create a new script with an increased number that describes the steps that need to take place. Then, again, after they have run once, they will not run again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.