Skip to content

Instantly share code, notes, and snippets.

@makoto
Last active December 23, 2020 17:40
Show Gist options
  • Save makoto/a743f1a73caf78b12eddf44d0bb11a69 to your computer and use it in GitHub Desktop.
Save makoto/a743f1a73caf78b12eddf44d0bb11a69 to your computer and use it in GitHub Desktop.
const Web3 = require('web3')
const Web3Legacy = require('web3legacy')
console.log('web3 version', (new Web3()).version)
console.log('web3 legacy version', (new Web3Legacy()).version)
// Do "export INFURA_PROJECT_ID=YOURPROJECTID" on your terminal
const projectid = process.env.INFURA_PROJECT_ID
const endpoint = 'https://mainnet.infura.io/v3/' + projectid
const provider = new Web3.providers.HttpProvider(endpoint)
const legacyProvider = new Web3Legacy.providers.HttpProvider(endpoint)
const web3 = new Web3(provider)
const web3legacy = new Web3Legacy(legacyProvider)
async function call(){
console.log('latest web3')
console.log('blocknumber', await web3.eth.getBlockNumber())
console.log('lagacy web3')
console.log('blocknumber', await web3legacy.eth.getBlockNumber())
}
call()
{
"name": "ethereum-ens-versions",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"ethereum-ens": "^0.7.7",
"web3": "^1.0.0-beta.55",
"web3legacy": "npm:web3@1.0.0-beta.37"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment