0

I first started ganache and see in the log that "Ganache started successfully" with the RPC Server set as: HTTP://127.0.0.1:7545

While running truffle migrate command, I've received the following message:

Could not connect to your Ethereum client with the following parameters:
    - host       > 127.0.0.1
    - port       > 7545
    - network_id > *
Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle-config.js)

Here is my truffle-config.js file:

require('babel-register');
require('babel-polyfill');
require('dotenv').config();

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    },
  },
  contracts_directory: './src/contracts/',
  contracts_build_directory: './src/abis/',
  compilers: {
    solc: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  }
}

I'm wondering if there's any way to check if the issue is the client can't accept RPC connections or if it's not accessible over the network as I don't think it's suggestions 1 and 4.

2
  • Which OS are you using? linux, mac, windows. Are booth truffle and ganache on the same machine with the same user?
    – Ismael
    Mar 10 at 2:30
  • Yes, same machine and using Windows 10. Mar 10 at 2:58
0

truffle migrate is used to deploy smart contracts to Ethereum networks (Ganache, public test nets and mainnet)!

In order to use truffle migrate you first need to have a smart contract in your ./Truffle/contracts folder

Then you say truffle compile to compile all the .sol files in the ./Truffle/contracts folder -> make sure to use a supported solidity version in your smart contract (you will get an error if yours isn't supported, just exchange your used version in the first line of your smart contract file with the required version)

Last but not least you need to go to ./Truffle/migrations folder to create 2_deploy_contract.js file containing following code:

const Migrations = artifacts.require("YOUR CONTRACT NAME");

module.exports = function (deployer) { deployer.deploy(Migrations); };

After all that you should be able to call truffle migrate and your smart contract gets deployed to your local Ethereum Ganache test net.

1
  • I have all of that in place, but for some reason can't get this to work off the ganache network. I believe it is likely some sort of security issue. Also, when I used the "truffle develop", the smart contract seemed to get deployed, but it wasn't on the ganache client accounts I expected. Instead it was some other set of accounts so I couldn't interact with the GUI. Mar 9 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.