This question already has an answer here:

How to use infura API with web3 js? Where should I put secret key?

marked as duplicate by Ismael, Achala Dissanayake, Richard Horrocks, shane, Briomkez Nov 2 '18 at 9:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


First, import web3 as such:

const Web3 = require('web3')

Then instantiate a variable (in my case web3) and set a provider:

const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_ACCESS_TOKEN:8545'))

Then you can use all the available web3 methods.

Hope it helped you!

  • 1
    This metod stopped working in browser right? It is telling about CORS headers – gkucmierz Nov 5 '18 at 15:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.