Truffle – How to Configure Truffle to Use the Ganache GUI Instead of Ganache-CLI (TestRPC)

testrpctruffle

I'm using Truffle v4.0.1 (core: 4.0.1) with the default configuration (ganache-cli aka TestRPC) on Ubuntu and it works fine, but I'd like to use the Ganache GUI. However, I can't find any instructions on how to configure them to work together. The Truffle documentation has a nice page explaining what it is and how it install and configure it, but not how to configure Truffle to take advantage of it. Thanks!

Best Answer

You'll need to add a development section to the networks section in your project's truffle.js:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 7545,
      network_id: "5777"
    }
  }
};

Make sure you get the port and network ID correct. Those are the defaults, so if you change them in Ganache you will need to change them here as well.

To use this specified network, after building the contract files, you'd use the command

truffle migrate --network development
Related Topic