0

I am wondering how a private chain can communicate through Metamask.

My biggest concern is the HttpProvider and accounts.

Aren't accounts accessed through the web3 instance?
Since accounts aren't shared over the network, aren't we only be able to access the accounts associated with the providing chain?
Is there anyway to dynamically access providers so that members aren't always using the same provider?

0

The provider provides you with the connection interface to the appropriate blockchain network. This blockchain network is reached by an address pointing to a certain node running and synced with the network.

That's why when we define an HttpProvider we pass the URL of the running node, it could be either:

  • Ganache local node
  • Infura remote node pointing to main/ropsten/rinkeby/etc...
  • Custom Get/Parity Node pointing to a private or public chain

Now after we setup our provider, we pass it to the web3 instance so it knows the node that we are dealign with.

For the Accounts part of your question, I can say that simply an account is a keystore located somewhere either at your machine or the node, but its private key is encrypted with the password that you provide to web3.

Regarding your last question, It's possible to have the same account dealing with different networks trough different providers. As I said the account is just a private/public key pair. But for sure every account/network pair is undefended and there's no interoperability between networks.

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.