I entered the command correctly but I am still getting this error:

TypeError: Cannot read property 'call' of undefined at evalmachine.:1:19 
at ContextifyScript.Script.runInContext (vm.js:35:29) 
at Object.exports.runInContext (vm.js:67:17) at TruffleInterpreter.interpret (/usr/lib/node_modules/truffle/lib/repl.js:99:17) 
at bound (domain.js:280:14) at REPLServer.runBound [as eval] (domain.js:293:12) 
at REPLServer. (repl.js:545:10) at emitOne (events.js:96:13) 
at REPLServer.emit (events.js:188:7) at REPLServer.Interface._onLine (readline.js:239:10)

I would really appreciate some help on the matter.

  • Can you edit the question to include the code? (Or a link to it.) – Richard Horrocks Feb 22 '17 at 8:24

Truffle uses Promises to handle asynchrony, that is why deployed() returns promise, not a contract instance.

So you need .then() to get instance:

HelloWorld.deployed().then(hello => console.log(hello.balance.call()))

Or you can expose contract instance as a global variable:

let hello;
HelloWorld.deployed().then(res => hello = res);

If you see HelloWorld has not been deployed error message then try to run truffle migrate or truffle migrate --reset before jumping to console.

Relevant Truffle doc page.

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.