0

I am building a simple contract.

In truffle when I give 'truffle develop' command, I get following information: enter image description here

On the Ganache, I have this: enter image description here

And finally on Meta Mask, I see this:

enter image description here

here, Shikhar is the custom RPC

I think the network which 'truffle develop' shows is the one where my contract is getting compiled.

I am not able to figure out how can I sync the network and accounts in these 3.

Please help.

Thanks

  • Doesn't look like a very good idea to post your private keys and those 12 words on a public website. – goodvibration Jul 30 at 12:15
  • This is just for testing. There are not of main network. – Shikhar Jul 30 at 12:58
  • I think you can't do that in an easy way. You can always manually import each account you get from Ganache into Metamask, but note that the accounts in Ganache will change every time you start a new instance, so it's not practical. Ideally, you'd disable the Metamask plugin when testing with Ganache in your browser. And then you'd test your contracts with Javascript directly, instead of using Metamask. – Daniel Portugal Jul 30 at 15:53
1

In your case you have 2 running blockchains. The first one is developement blockchain spawned by truffle and you can access its rpc using :

http://127.0.0.1:9545 as shown in your terminal

and the second one is ganache's chain which you can access its RPC using http://127.0.0.1:7545

If you are deploying your contract using Truffle look at truffle.js file

and then points Metamask to the chain you've configured there.

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 7545,
      network_id: "5777"
    }
  }
};

once connected import the first account which indicated in truffle's console.

  • H, thanks for your comment. I think the problem lies with my limited knowledge of Blockchain technology. I have further questions related to this. 1) I have only truffle-config.js file in the installed folder. is that the same as truffle.js file mentioned in your comment? 2) If I add the network in truffle-config.js file as you mentioned, then my smart contract will compile and deploy on that network right? 3) Is there any source using which I can better my understanding of these concepts? Thanks :) – Shikhar Aug 1 at 7:13
  • truffle-config.js is the same as truffle.js it's used normally in windows environment . 2-if you keep devlopment network yes but if you add more networks you have to specify which one are you using when you start truffle (truffle --network "network name") 3-trufflesuite.com/docs/truffle/reference/configuration – Badr Bellaj Aug 2 at 16:14
  • @Shikhar if my response answer your question don't forget to mark it as accepted ;) – Badr Bellaj Aug 2 at 16:15

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.