[Ethereum] MetaMask and Access Ethereum Private Chain from other PC in the same network (for test)

bootnodesmetamasknodesprivate-blockchain

My goal: To simulate the Ethereum blockchain with different clients. So, they create their own accounts, i.e. public/private keys, and store them locally. So all are for testing.


Assume, I have set up a private chain on computer A. Can I install MetaMask on computer B, and connect to computer A's private chain?

If YES, how can I do that?

If NO, how can I connect two nodes (each on a different machine and having the regular IP address, not a static one) so they can connect to the private chain with a minimal setup?

Best Answer

You can do it with using both ways, having the two computers networked together.

Using Metamask;

select network as Custom RPC put the custom url as http://[ComputerA's ip address]:[rpc port]

eg:

If computer A's ip address is 192.168.8.100 and rpc port is 8545 then use,

http://192.168.8.100:8545

enter image description here enter image description here

Using web3;

As one of your own questions How can I connect my HTML user interface to my Ethereum private chain? you can use

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

with the slight change of; instead localhost replace the ip address of the other computer (in your case computer A's ip address in the LAN) and the 8545 with port number.

eg:

If computer A's ip address is 192.168.8.101 and rpc port is 8545 then use,

web3 = new Web3(new Web3.providers.HttpProvider("http://192.168.8.101:8545"));

EDIT: It's needed to have RPC enabled in the computer A allowing the computer B to access it with

--rpc --rpcport "8545" --rpccorsdomain "[commputer B's ip address OR *]" --rpcaddr "[computer A's ip address]" 
Related Topic