I have parity running on one terminal with:
parity --chain kovan ui
Then on Atom I try to attach with:
Web3 = require("web3")
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log(web3.eth.blockNumber)
When I run it with atom-runner or a node terminal I get undefined.
Running Parity/v1.6.10-stable,node 8.5.0/ web3 1.0.0-beta.20
Of course I figured it out after a minute of posting the issue:
npm installs version 1.0 of web3, uninstalling it and installing v '0.20.2' resolved my problem.
KenoLeon, Hi, how did you uninstall it and install the lower version?
Have problems seems the same with that yours.
@albomo check:
https://medium.com/@k3no/ethereum-tokens-smart-contracts-a263b43d4c54
Basically npm view web3 versions to view versions and then something like npm install [email protected] to install , also check that your are on the latest parity release, things change so fast that I'd recommend you check the beta changelogs .
I see this is an older thread, but I wanted to ask -- the web3 documentation says that HttpProvider is deprecated, so I wonder if that's why it doesn't work with the newer versions of web3. It looks like this is only as related to subscriptions, so I guess its not that important if you're not using those?
But I wonder if the proper approach is to use the newest version of web3 and use websockets instead? See the discussion of these different methods in the web3 documentation: https://web3js.readthedocs.io/en/1.0/web3.html
Most helpful comment
Of course I figured it out after a minute of posting the issue:
npm installs version 1.0 of web3, uninstalling it and installing v '0.20.2' resolved my problem.