0

I wanted to run web3.js in the browsers of my users. The tasks range from extracting token name and token symbol from token address to deploying contracts.

But for example Ethereum Wallet starts slowly. I assume (right?) that web3.js would also load slowly.

What are the ways to overcome this problem? Should I run a node (which software does this?) on my server? If yes, can I make my node to serve only to my clients (not to everybody in the Net) in order not to become slow?

Or maybe the above described problem makes using web3.js unfeasible at all? Should I instead interact with the user using Python (my primary programming language for the project) AJAX, without web3.js?

2

Web3.js does not load chain data, so it is not slow like an Ethereum Wallet while syncing the chain. You configure web3.js to point at a trusted Ethereum node.

You might want to check out a service like Infura if you do not want to host your own node.

EDIT:

Showing example timing on a basic get operation from Metamask (pointed at Infura).

enter image description here

  • How much time (in seconds) would it take to get token name and token symbols for a given address? – porton Mar 28 '18 at 17:50
  • @porton less than 1 second. I edited my answer with an example timings for a basic get operation (via Metamask) to Infura's nodes. – Nico Valencia Mar 28 '18 at 22:32
1

Nico is correct - you simply point web3 to a node (local or remote). Usually this is done by configuring MetaMask. Choosing local vs remote depends on your trust model.

  • Remote: If you want something light weight, point MetaMask to the default Infura node. This means you do not need to run a local node or download the blockchain at all.
  • Local: If you are not willing to trust a remote node (e.g. Infura), then download your own copy of the blockchain, run a node, and point your Metamask to your local node instead.

Web3 will operate using whichever you choose.

  • How much time (in seconds) would it take with a typical remote node to get token name and token symbols for a given address? – porton Mar 28 '18 at 17:50
  • 1
    Super quick. Metamask polls the remote node every 1 second. – Ryan Miller Mar 28 '18 at 18:46

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.