1

I have such code before

let profit = await contract.methods.calculateFundProfit().call()
   profit = web3.utils.hexToNumberString(profit._hex)

but after update web3 version, do I need do only this?

let profit = await contract.methods.calculateFundProfit().call()
  • What was your web3 version before and what is it now? – goodvibration Aug 13 at 14:29
  • There is generally a lot of confusion about web3 versions. First of all, Truffle 4.x relies on Web3 0.x, and Truffle 5.x relies on Web3 1.x. Between these two versions of Web3, there are API differences, which means that your code breaks when you move from one version to the other. Second - even worse - Web3 1.x has been published as a Beta version up until 55, and then finally as a Release version 1.2.x, which relies on... Beta 37... – goodvibration Aug 13 at 14:34
  • So if you've updated to 1.2.x, then it is rellay a question of "where you came from", for example - was it 0.20.6 or 1.0.0-34 or 1.0.0-55? Each case would yield a different set of problems in your code. – goodvibration Aug 13 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.