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)
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 – Ujjwal Vaish Apr 2 '17 at 22:48
  • which truffle do you have – Badr Bellaj Apr 2 '17 at 23:01
  • I have truffle v3.2.1 – Ujjwal Vaish Apr 2 '17 at 23:03
  • I redeployed my contract, re-run testrpc and it worked! – Ujjwal Vaish Apr 3 '17 at 3:27

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.