Within my truffle console I'm running web3.version.network and it's returning '1514147182983'. When I check the accounts under web3, it's still connected to testrpc. How do I transition this to my testnet (Rinkeby, Ropsten, etc) accounts?


Configure the networks you'd like to use in truffle.js:

const HDWalletProvider = require('truffle-hdwallet-provider')

const mnemonic = "word1 word2 ... word12"

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' 
    rinkeby: {
      provider: new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io'),
      network_id: '*',
      gas: 4712383,
      gasPrice: 20000000000
    mainnet: {
      provider: new HDWalletProvider(mnemonic, 'https://mainnet.infura.io'),
      network_id: 1,
      gas: 4500000,
      gasPrice: 10000000000

Set the network flag to a specified network:

$ truffle --network=rinkeby console

Get network ID in truffle console:

truffle(rinkeby)> web3.version.getNetwork((err, network) => console.log(network))
truffle(rinkeby)> 4

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .