0

Currently getting this error in my Browser's Console:

enter image description here

My current set up is as follows:

Truffle v5.0.3 (core: 5.0.3)
Solidity - 0.5.0 (solc-js)
Node v8.9.4

Here's my code - and note that I'm using .Contract with a CAPITAL C, which I believe is the new, Solidity - 0.5.0 way of doing this:

 App.MathContract = new web3.eth.Contract(
      [
        {
          "inputs": [],
          "payable": false,
          "stateMutability": "nonpayable",
          "type": "constructor"
        },
        ....

Interestingly, when I used the old syntax - .contract with a lower-case c, I do not get this error:

App.MathContract = App.web3Object.eth.contract(
      [
        {
          "inputs": [],
          "payable": false,
          "stateMutability": "nonpayable",
          "type": "constructor"
        },
        ....

Any thoughts about what I'm doing wrong? (I'll be happy to upload any other code that might fill in the gaps.)

============================================

UPDATE:

Here's what my web3 version looks like:

enter image description here

  • Which version of web3 are you using in the browser? How web3 is initialized? – Ismael Feb 2 at 20:41
  • Could you please run npm ls web3 and provide the printout? – goodvibration Feb 2 at 21:17
  • Running npm ls web3 yields web3@1.0.0-beta.41. See updated question above - I provided a screengrab of this query. – Sirab33 Feb 3 at 14:18
  • Your description strongly implies that are using version 0.x. I believe that if you try to run your code directly with node (from a command line) instead of from your browser's console, then this error will not appear. If I'm right, then it means that your browser somehow relies on web3.js v0.x. – goodvibration Feb 3 at 14:30
  • I think it might have something to do with the way web3.min.js is being imported - or NOT being imported into the project... I do have it in my js folder, which is inside my src folder, which is sitting inside my Project's folder - right alongside all the required folders (migrations, contracts, node_modules, etc.) - but I don't know if its getting read when running the project on localhost:3000 (which is launched when I do npm run dev) – Sirab33 Feb 3 at 14:48

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.