How to Connect to the Ethereum Blockchain in Code

Jared Stauffer
1 min readFeb 19, 2019

--

Prerequisites:

  1. NPM and Node.js (install via instructions at the link)
  2. Web3.js (install from a command line: npm install web3)
  3. Infura Endpoint — create a free account, go to dashboard, by ENDPOINT select MAINNET, copy the end point URL, put it in the code below

Create a file with the code below, save it as app.js, run with “node app.js” in a terminal window.

If you did everything correctly you should see a number printed out to the screen, like 7241532.

To continue the fun, see the Web3js docs, and extend the code to do more!

If this was helpful, give me some claps and share! And reach out js (at) stauffer.co or @jaredstauffer on Twitter.

--

--

Jared Stauffer
Jared Stauffer

Written by Jared Stauffer

CTO, Technology Leader, Innovator 🚀

No responses yet