Configuring Truffle

Now, it is time to configure Truffle. First, we need to define the networks to which we want to migrate the contracts. In the truffle.js file (truffle-config.js for Windows), insert the following code:

module.exports = {
networks: {
my_ganache: {
host: "127.0.0.1",
port: 7545,
network_id: "*"
}
}
};

We define a deployment network with the name my_ganache along with a few parameters. The network name is used for user-interface purposes, to help you easily choose to run your migrations on a specific network with a name, as we can configure Truffle to use multiple networks.

Basically, this configuration file says to Truffle that when we choose the my_ganache network, connect to the host at 127.0.0.1, using port 7545. For network_id, we used * to match any network ID. Beyond that, there are many other configuration options, such as gas limit and gas price, which are detailed in the documentation: https://truffleframework.com/docs/truffle/reference/configuration.

..................Content has been hidden....................

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