TL,DR: Is anyone also experiencing problems with the Web3JS documentation?

I am very confused by the API documentation of Web3Js because of its behaviour.


var myContract = new web3.eth.Contract(abi, address);

Error: VM4943:1 Uncaught TypeError: web3.eth.Contract is not a function at :1:10

But when I use...

var myContract = new web3.eth.contract(abi, address);    // Minor c

it is working just fine.


var contract2 = contract1.clone();

Error: VM5261:1 Uncaught TypeError: contract3.clone is not a function at :1:11


My aim is to create a default contract (already done), clone/copy it. But I am stuck where it comes to receiving the contractAddress from the newly created contract:

var SampleContract = eth.contract(abi);

var contractInstance = new SampleContract.new(30, {data: byteCode, from: firstAccount, gas: estimate, gasPrice: estimate});


Thank you in advance!


You're reading the documentation of version 1.x, but you're using version 0.x.

  • Thanks for the quick response :) I am using 1.2.7 (cdn.jsdelivr.net/npm/web3@1.2.7/dist/web3.min.js) and also reading it... Apr 28 '20 at 18:58
  • @Hashtag3232: No you're not! The syntax web3.eth.contract (with a lower-case c) is of v0.x. Note that you may have web3.js v1.x installed in one place and web3.js v0.x installed in another place, which is where your script imports it from. For example, if you're using Truffle v4.x or lower, then it internally relies on web3.js v0.x. So in all of your Truffle tests, web3.js v0.x will be automatically (and implicitly) imported. Apr 28 '20 at 19:02
  • Thanks! I am using Wordpress it was somehow already an old version installed (0.2.0) -> var version = web3.version.api; Apr 28 '20 at 19:54
  • @Hashtag3232: You're welcome. Apr 28 '20 at 19:57

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.