0

I followed the steps in the following link to create a local Ethereum testnet, but now I want to deploy a contract to "MyTestNetNode":

https://medium.com/@WWWillems/how-to-set-up-a-private-ethereum-testnet-blockchain-using-geth-and-homebrew-1106a27e8e1e

testrpc wasn't a good option because test rpc doesn't save the state when you stop the daemon. I need to create a testnet with geth which I have already done and I would like to deploy a contract to it using Truffle without getting errors. Can anyone help me?

1

2 Answers 2

1

All you need is to change the truffle config file according to your local configuration:

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545, //the port of your local testnet
      network_id: '*' //any network ID
    }
  }
}

in top of that you can actually use also ganache-cli as testrpc client and add the parameter --db to save the database. In this way you can run the test node again using the saved data instead of starting from a new one anytime

0

In my experience it is easier to use test networks, like Rinkeby or Ropsten. Your state would be saved for later use. You just need to have ether for those networks. Just search for faucet for Rinkeby for example and you will find a website that gives you a fake ether to use on this network.

Then set the truffle-config like this:

rinkeby: {<
    provider: () => new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/v3/${INFURA_KEY}`),
    network_id: 4,       // Rinkeby's id
    gas: 5500000,        // Rinkeby has a lower block limit than mainnet
    confirmations: 1,    // # of confs to wait between deployments. (default: 0)<
    timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
    skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
  }

And then run truffle deploy --network rinkeby

Note: you can define your own private network here too. Just define a name for your network and assign the ip, port and other things. Here I use Infra to access Rinkeby, which is, again, easier for development purposes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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