Categories
Javascript

How to Add Multiple Migrations in Truffle?

Migration, in general, is a very much known term for developers in different aspects. In general, it is the process of moving your application from one operating environment into another operating environment to upgrade it. But most of the backend developers use it to define the schema of your database. 

In Ethereum blockchain we need to migrate the Smart Contract to the blockchain. This can easily be done using a truffle framework. 
Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. With Truffle, you get: … Scriptable deployment & migration framework. It acts as network management for deploying to many public & private networks.

Here I want to show how you certainly run the migration using a truffle framework when you have single or multiple smart contracts in one or multiple solidity files.

If you have a single solidity file with multiple migration addresses, the framework by default establishes the relationship between them. And thus, any smart contract can use the defined functions from its parent address inserted.

For example, here I have created a solidity file of three smart contracts and deploy it.

However, if you have multiple solidity files created with smart contracts and want to establish the relationship between those smart contracts, you need to pass the address from one to another smart contract.

For example, here contract two is inherited from contract one:

By defining these codes, I am perfectly able to access the functions defined in Smart Contract One after migrating it to Smart Contract Two.

Add this set of code blocks and establish an inheritance between your multiple solidity files. Get it done and share how it works for you.

Does this helpful for you? Yes/No