0

For whatever reason, when I attempt to set an instance of a contract in a javascript file, I get the following message in my console:

Uncaught TypeError: web3.eth.Contract is not a constructor 

At first, I suspected I had a problem with properly setting my Web3 instance, but when I run:

console.log(web3);

The console shows that I the web3 instance is set.

I try and set my the contract instance using the following code:

const myContract = new web3.eth.Contract([//json array]);

Any tips for solving this?

  • 1
    This is for v1.x, you're probably still on v0.x. You can check it via npm ls web3. For v0.x, remove the new and change Contract with an upper-case C to contract with a lower-case c. – goodvibration Jul 8 '19 at 15:19
  • Thank you goodvibration, that solved my problem. How do I give you credit for the answer? – Julian Martinez Jul 9 '19 at 13:27
  • 1
    I added it as an answer, so you can give it a credit... – goodvibration Jul 9 '19 at 14:04
0

This is for v1.x, you're probably still on v0.x.

You can check it via npm ls web3.

For v0.x, remove the new and change Contract to contract.

| improve this answer | |

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.