[Ethereum] how to deploy smart contract in ethereum network using ropsten network

ethereum-wallet-dappropstensoliditytestnetstokens

I have created a smart contract(a standard token smart contract) in solidity and truffle. Now I want to deploy it to ethereum network. I want to use ropsten network because I want to use metamask wallet. How to do it? Or what is the best way to deploy it in ethereum network?

Best Answer

You need to use truffle-hdwallet-provider and provide it your wallet mnemonic. The mnemonic is the 12 word phrase which addresses are created from. The wallet should have testnet ether already loaded, which you can get from faucets.

Here's how I've been deploying to different testnets:

In truffle.js:

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

const mnemonic = process.env.MNEMONIC

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

Then just run:

truffle migrate --reset --network=rinkeby
Related Topic