I got the following JS error:

JavaScript error: index.html - line 15 - Uncaught TypeError: Cannot read property 'contract' of undefined

whenever I tried to enter a name and a rating in store fields to add a new rating.

How do I fix this?

Mix IDE error

  • What exactly are you trying and where do you get that error? Please add some more details to your question or else nobody would be able to help you in detail. Screenshots sometimes also do the trick.
    – Afr
    Mar 25 '16 at 20:22

I'm pretty sure that in the scenario part on the right of the IDE, you haven’t created the contract Rating. So you need to click on the Add Transaction button and create it. After that problem solved ;)

enter image description here

  • Thankns @euri10 otherwise yes I had created the "Ratings" transaction.
    – Kizito
    Mar 28 '16 at 22:11
  • 1
    Then I don't get it. Your error says exactly that the contract method can't be called on undefined hence why I thought you had not created it. Furthermore using the tutorial code I can raise the same error if the contract isn't created.
    – euri10
    Mar 29 '16 at 6:07
  • Could you clarify where Add Transaction option can be found? Is it somewhere in menu?
    – kenorb
    May 6 '16 at 11:16

From the code, it seems that it is bound to crash at that line if there is no contract of that name in existence.

I ran that same sample Dapp and I get EXACTLY that same error when the contract has not been created. The code works fine as soon the contract is created! euri10 has got it spot on!

  • Yes he did. What I also tried doing was to just create a new scenario. This automatically synced everything.
    – Kizito
    Apr 8 '16 at 14:55

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.