I want to use power of Eth to enable payment and some rpc related operations to my app. Which version(1.0 beta or 0.+) of webjs I need to use. May I know why?
2 Answers
You don't have to move to the new version if you don't have any issues with the one you are currently using. The new web3 1.0 version is still in beta and there is no official release date yet so there is no need to upgrade.
Some important changes of the new version include:
- Events - changed the way we listen to Smart Contract Events.
- HttpProvider is no longer supported for events.
- WebsocketProvider is the web3 1.0 way of listening to events via subscribe/unsubscribe
- Returns - majority of the returns have been converted into Promises. Additionally previous functions that returned
BigNumber
are now returning aString
representation of that number. - Utilities - utility functions (
fromWei
,toWei
, etc.) have been moved into aweb3.util
package - Modularization - a lot of refactoring has been made to decouple the web3 modules and make it possible to use them individually.
If you want to know if any specific functionality has been changed you can find more on their wiki page: web3.js 1.0 documentation
Te web3js version 1.0 is actually better than the old version and feels more modern and much more intuitive. The semantics of the methods are basically the same between the 2 versions but the declarations, output, and input of each method has changed a lot. If you are already using the 0.x version, just keep using it. If you didn't start with web3 yet, go to version 1.0.
NOTE : You may not find many tutorials to start with on version 1.0 since it is not that stable, yet.
-
1the confusing thing I find with 1.0 beta version is the removal of personal api. In 0.2x.x I use
web3.personal.unlockAccount
to unlock the account and then right after call a method on my contract. But in the beta version, I dont know how I do this since there is nounlockAccount
. So what is used in 1.0beta to unlock the account so I can call my contract?– ChipeJun 25, 2018 at 22:23