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.
    – q9f
    Commented Mar 25, 2016 at 20:22

2 Answers 2


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
    Commented Mar 28, 2016 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
    Commented Mar 29, 2016 at 6:07
  • Could you clarify where Add Transaction option can be found? Is it somewhere in menu?
    – kenorb
    Commented May 6, 2016 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
    Commented Apr 8, 2016 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.