I'm working on an open-source project.

I'm hesitant to include web3.js with all the code.

I just want to read a single value from the Ethereum blockchain.

That is why my requirement is to avoid 100KB libraries.

  • 2
    The problem is that it's not so straightforward. You either have to use some external service (such as Etherscan API) or then query a node directly. If you want to query a node directly you need to run your own node or have access to some shared node (Infura for example) - all of that is much easier with libraries. Mar 3 '20 at 10:30
  • You can use Etherscan Developers APIs, then you'll just need to require("request"). Mar 3 '20 at 10:42
  • Thanks, using Etherscan API should be simple enough, can make a web request without involving any libraries. Trusted 3rd party kind of sucks but it's a reasonable risk-reward ratio, nothing too critical. Mar 3 '20 at 11:31

You could just use a HTTP POST request to a geth or parity node.

Here is the documentation with examples using curl: https://github.com/ethereum/wiki/wiki/JSON-RPC

Instead of curl, just use a HTTP request and POST the data.

You'll need to make sure your local node allows connections. I use this something like this: geth --rpcapi eth,net,web3 --rpccorsdomain * --rpc --rpcaddr

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.