-
Notifications
You must be signed in to change notification settings - Fork 109
Description
I'm facing this issue on node.js on local test network the code is working fine but not on the main ethereum or remote test network it is throwing an error
const Web3 = require('web3'); var currentProvider = new Web3.providers.HttpProvider('ropsten.infura.io/v3/api_key'); const web3 = new Web3(currentProvider) const account_addr = '0X0' web3.eth.getBalance(account_addr , function (error, result) { if (error) { console.log(error) } else { console.log(result) } })
Error:
Error: Unsupported protocol null at new NetworkError (D:\blockchain\web3_examples\node_modules\xhr2-cookies\dist\errors.js:32:42) at XMLHttpRequest.send (D:\blockchain\web3_examples\node_modules\xhr2-cookies\dist\xml-http-request.js:156:23) at D:\blockchain\web3_examples\node_modules\web3-providers\dist\web3-providers.cjs.js:771:19 at new Promise (<anonymous>) at HttpProvider.sendPayload (D:\blockchain\web3_examples\node_modules\web3-providers\dist\web3-providers.cjs.js:744:14) at HttpProvider._callee$ (D:\blockchain\web3_examples\node_modules\web3-providers\dist\web3-providers.cjs.js:707:29) at tryCatch (D:\blockchain\web3_examples\node_modules\regenerator-runtime\runtime.js:45:40) at Generator.invoke [as _invoke] (D:\blockchain\web3_examples\node_modules\regenerator-runtime\runtime.js:271:22) at Generator.prototype.(anonymous function) [as next] (D:\blockchain\web3_examples\node_modules\regenerator-runtime\runtime.js:97:21) at asyncGeneratorStep (D:\blockchain\web3_examples\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)