18

i'm noob, I want to deploy my contract on Ropsten network with MetaMask & Truffle, plz explain to me the steps to deploy it.

closed as too broad by Rob Hitchens - B9lab, Richard Horrocks, lungj, Matthew Schmidt, Joël Aug 1 '17 at 0:55

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Hi there. I think your question will be flagged as being too broad, I'm afraid. You could ask somewhere like Reddit, and then if you have specific problems, ask them here. www.reddit.com/r/ethereum – Richard Horrocks Jul 30 '17 at 11:16
31

Solution 1: With you own node

You can easily deploy on the ropsten network if you own a full node running on your machine.

i. Run geth

$ geth --fast --cache=1048 --testnet --unlock "0xmyaddress" --rpc --rpcapi "eth,net,web3" --rpccorsdomain '*' --rpcaddr localhost --rpcport 8545

ii. In truffle.js, add the following configure for the ropsten network

module.exports = {
  networks: {
    localhost: {
      host: "localhost", 
      port: 8546,
      network_id: "*" 
    },  
    ropsten: {
      host: "localhost",
      port: 8545,
      network_id: "3"
    }
  }
};

iii. Deploy on the ropsten network

$ truffle migrate --network ropsten

Solution 2: With a public node like Infura

i. Install the needed libraries

Navigate into the project folder and run the following command:

npm init

npm install truffle-hdwallet-provider --save

ii. In truffle.js, Add the following code to unlock your Metamask account and configure the Infura Ropsten node as entry point by providing the mnemonic phrase (Metamask / Settings / Reveal Seed Words)

var HDWalletProvider = require("truffle-hdwallet-provider");

var infura_apikey = "XXXXXX";
var mnemonic = "twelve words you can find in metamask/settings/reveal seed words blabla";

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
      network_id: 3
    }
  }
};

iii. Deploy on the ropsten network

$ truffle migrate --network ropsten

EDIT: Replace the solution by truffle-hdwallet-provider.Way more simple solution than ethereumjs-wallet bip39 web3-provider-engine web3

  • 2
    Do i need download all blocks? – TahaBA Jul 31 '17 at 11:28
  • With the first solution, you need a local synchronised full node (all blocks). The second solution relies on a third party with a fully synchronised node, you don't need a node at all – Greg Jeanmart Jul 31 '17 at 11:30
  • i have error when i run second solution Error: Cannot find module 'ethereumjs-wallet/hdkey' – TahaBA Jul 31 '17 at 12:38
  • Hi, sorry I forgot one point in the second solution. You need to execute this command first: npm install ethereumjs-wallet bip39 web3-provider-engine web3 --save (I edited the answer with the details) – Greg Jeanmart Aug 1 '17 at 9:43
  • 1
    I pushed my code on github to give you an example : github.com/gjeanmart/stackexchange/tree/master/… – Greg Jeanmart Aug 1 '17 at 22:03

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