[Ethereum] what is the role of Migrations.sol contract in truffle project

truffletruffle-migration

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?

Best Answer

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

Related Topic