0

My Dapp was working fine, but after I upgraded web3.min.js to the most recent version, I am getting these errors.

Uncaught TypeError: (intermediate value).toBigNumber is not a function

Uncaught ReferenceError: TruffleContract is not defined

initContract: function() {
    $.getJSON('Pets.json', function(data) {
      App.contracts.RealEstate = TruffleContract(data);
      App.contracts.RealEstate.setProvider(App.web3Provider);
    });
},

Seems like the new web3 doesn't recognize some parts in truffle-contract.js or the other way around. Any fix for this?

  • Truffle uses web3 v0x, which implements function web3.toBigNumber, while the equivalent function implemented in web3 v1x is web3.utils.toBN. Moreover, the objects returned from these two functions are different!!! One way to solve your problem is by forcing the old web3 version in your package.json file. – goodvibration Jul 30 '18 at 20:20
  • Thanks for your comment! Now I have to use web3 1.0 because I need to use create() function that exists in 1.0 version. If truffle doesn't support 1.0 then should I manually import abi from artifact file and use it to instantiate it? – bbusdriver Jul 30 '18 at 20:36
  • I am unable to answer your question without seeing actual code (and to be honest, I cannot really understand much from the code that you have posted). – goodvibration Jul 31 '18 at 8:07
  • There's a branch of truffle that support web3 v1.0 github.com/trufflesuite/truffle/tree/next but it is also in beta so it might not work properly. – Ismael Aug 1 '18 at 14:50

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.