I don't get it. I've seeing two ways from tutorials on how to instantiate web3.

One is..

eth = new Eth(web3.currentProvider)
token = eth.contract(abi).at(contract_address);

and another is..

web3 = new Web3(web3.currentProvider);
token = new web3.eth.Contract(abi, contractAddress);

How are they different? And I can't find info on https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html with the small "c" for contract.


I think I know why. Small "c" is for web3 version below 1.0. Lowercase "c" and no "new". While big "C" is for version 1.0++.

Gosh, why they make like difficult for coders.

  • This is indeed the case. In web3 v0.x, use web3.eth.contract. In web3 v1.x, use new web3.eth.Contract. – goodvibration May 13 '19 at 8:05
  • I have to add that usually class names are capitalized by convention, while it's attributes aren't, as you can see in new Eth, new Web3 and new web3.eth.Contract. – Carlos Fuentes May 25 '19 at 3:43

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.