Web3js – Difference Between Truffle-Contract and Web3.eth.Contract

truffle-contractweb3js

maybe this is a very simple question but I've tried unsuccesfully to understand the difference between truffle-contract and web3.eth.Contract from web3.js 1.0.

As far as I've understood they seems to me two different module used for working with smart contracts' abstraction.

Am I missing something?
If they both serve the same purpose which one should I use (functionalities, easy-to-use,ecc)?

Thanks.

Best Answer

As pointed out by @Ismael in the comment and after some days spent working with both library I can confirm what he has written.

Truffle-contract is based on the stable version of web3 (v0.20), so it use promises and allow you to perform contract operation and methods in Javascript.

Web3 v1.0.0 (which is still in beta) use Promise and Promievents, so web3.eth.Contract allows you to interact with your contract like truffle-conctract but it has in my opinion more funcionalities.

One thing to note is that the utility of truffle test docs and docs gives you an istance of web3 and truffle-contract so (if I'm not wrong) you can't for now use web3.eth.Contract in .js truffle test.

Related Topic