1

Let's say there is a web application running on server 12.34.45.45 ip. Peer A open this web application in his own browser.Now how he will be able to connect a ethereum node where peer B is running.Please note ip of peer A,peer B are different from the ip where web server is running i.e. 12.34.45.45.

2

I'd suggest you shall not make your UI directly talk to your ethereum node because its not safe to expose the node directly to UI.

however, you shall try and create a middleware in nodejs to communicate to Ethereum backend.

In nodejs middleware you can use web3js api to connect with your ethereum node.

We have recently created such middleware APIs in node.js. You can take a look at this repo for reference -

https://github.com/Imaginea/lms/blob/master/server/routes.js

The UI talks to node.js middleware and then middleware talks to Ethereum node.

Hope this helps.

  • "I'd suggest you shall not make your UI directly talk to your ethereum node because it's not safe to expose the node directly to UI." - There is nothing inherently unsafe in communicating directly with a node.. – Thomas Clowes Jul 4 '17 at 14:35
  • If any geth Node is openly accessible, then I can directly connect with it to get some information that how many accounts present, what are the balances etc. So i generally feel that it's not good to expose the node directly. – Sanchit Jul 4 '17 at 14:42
  • True. Exposing a node with stored accounts is foolish. I would however assume that if this user is setting up a node for a web application to interface with then he/she would not 'add' accounts to it. – Thomas Clowes Jul 4 '17 at 14:44
  • It may depend on the use case, the recent project which I did had the requirement of creating an account for every new member of the app. So we had to introduce middleware. – Sanchit Jul 4 '17 at 14:46
1

Via embedde web3 in the client's browser. Thus, the client's browser needs web3. Best way to do it is MetaMask. In MetaMask, the user (client) can configure the node. MetaMask comes with some central nodes, so the user (client) actually does not need to setup any node. This is how I do it, e.g. http://www.chainify.io

1

If you are planning to use web3 as a javascript api, you can specify url to ethereum node as a HttpProvider:

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

If you know the ip of a client you may put the additional restriction on the Peer B server (firewall) only to accepts connection on port 8545 from the client ip.

In may also consider using Metamask browser plugin or publically available Infura node if you don't have strong security reasons to host your own Ethereum node.

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.