4

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

eth
  • 85,679
  • 53
  • 285
  • 406
gkucmierz
  • 773
  • 2
  • 8
  • 15

1 Answers1

8

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!