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

| improve this 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!

| improve this answer | | | | |
  • 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.