2

How can I define in truffle the ipc connection to the node? Currently I am using in truffle.js host/port fields, which are used to create a HttpProvider.

module.exports = {
  networks: {
    dev: {
      host: "localhost",
      port: 8545,
      ...
    }
  }
}
3

According to https://truffleframework.com/docs/truffle/reference/configuration there is a field called provider. Using this field an arbitrary web3 connection provider can be injected.

For IPC on Windows it looks like:

var Web3 = require("web3");
var net = require("net");

module.exports = {
  networks: {
    dev: {
      provider: function() {
         return new Web3.providers.IpcProvider("\\\\.\\pipe\\geth.ipc", net);
      },
      ...
    }
  }
}

Note: Additionally to truffle, you'll have to separately install web3 and net npm packages: npm -g install web3@0.20.7 net.

| improve this answer | |

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.