1

This is my contract-

pragma solidity ^0.4.0;
contract helloworld { 
     uint public balance;
    function helloworld(){
        balance = 1000;
    }

    function getBalance()  returns(uint) {
        return balance; 
    } 
}

I ran truffle compile and truffle migrate. Then I'm trying to access the balance variable by

helloworld.deployed().balance.call();

I'm getting the following error-

TypeError: Cannot read property 'call' of undefined
    at evalmachine.<anonymous>:1:30
    at ContextifyScript.Script.runInContext (vm.js:35:29)
    at Object.runInContext (vm.js:89:6)
    at TruffleInterpreter.interpret (C:\Users\ujjwa\AppData\Roaming\npm\node_modules\truffle\lib\repl.js:136:17)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:538:10)
    at emitOne (events.js:96:13)
    at REPLServer.emit (events.js:188:7)
    at REPLServer.Interface._onLine (readline.js:230:10)

1 Answer 1

0

if you use truffle V3.x (truffle version) try

helloworld.deployed().then(function(instance){helloworld=instance})

then

helloworld.balance.call()
4
  • Getting this error- Error: VM Exception while executing eth_call: invalid JUMP Commented Apr 2, 2017 at 22:48
  • which truffle do you have
    – Badr Bellaj
    Commented Apr 2, 2017 at 23:01
  • I have truffle v3.2.1 Commented Apr 2, 2017 at 23:03
  • I redeployed my contract, re-run testrpc and it worked! Commented Apr 3, 2017 at 3:27

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.