Preparing the migration

Truffle uses the migration concept to refer to deploying and switching old contracts to new instances. To deploy our hello world contract, we need to indicate to Truffle how to deploy (migrate) it into the blockchain. To achieve that, open the migrations/ folder and create a new migration file named 2_initial_migration.js.

Paste the following content into this migration file :

const Hello = artifacts.require("HelloWorld");
module.exports = function(deployer) {
deployer.deploy(Hello);
};

At the beginning of the migration, we tell Truffle which contracts we would like to interact with via the artifacts.require() method, in the same way we do with require in Node.js.

In the case where you have multiple contracts defined, you'll need to define an artifacts.require() statement for each contract:

var ContractOne = artifacts.require("ContractOne");
var ContractTwo = artifacts.require("ContractTwo");
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset