Search code examples
blockchainethereumsolidityweb3jstruffle

Which web3 version is correct?


I checked my web3 version in two way, and those two show different web3 version.

This is one

$ npm ls web3
[email protected] /Users/__/Desktop/MyApps/eth_todo_react/frontend
└── [email protected]

This is two

var version = web3.version.api;
undefined
version
"0.20.3"

Which one is correct web3 version?


Solution

  • Neither is correct or wrong.
    1.0.0-x is still in beta.
    On the other hand 0.2x.x is more stable but it lacks some features such as Promises, WebSockets(even though 1.0.0 isn't doing that great at websockets at some point)

    After all you can't go wrong with either one. Just refer to the corrects docs:
    Docs for web3.js 0.2x.x
    Docs for web3.js 1.0.x-x