What is the difference between

 instance.totalSupply() vs instance.methods.totalSupply().call()

To my knowledge one is for truffle and the other is for web3. But truffle also uses web3 then why can i not call the functions in a single way?


From web3.js version 1.0 it has been recommended to call smart contract functions like this


Reference : methods

For earlier version ( < 1.0) we could call like


Note : from docs

This documentation is work in progress and web3.js 1.0 is not yet released! You can find the current documentation for web3 0.x.x at github.com/ethereum/wiki/wiki/JavaScript-API.

  • which web3 version is truffle using? – Kashish Khullar Sep 30 '18 at 17:57
  • I am not sure. you can check it – sharif2008 Sep 30 '18 at 18:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.