4

Is there a way to call a contract with no arguments using async? Contract code:

contract A {
     function test() constant returns(string s, address addr) {
        s = "Success!";
        addr = msg.sender;
    }
}

Here is the js code:

async.waterfall([
        function getResult(cb) {
      contractObject = web3.eth.contract(abi);
            contractInstance = contractObject.at(address);

      contractInstance.test.call(
  function(err,getOutput) {
       if(err) {console.log(err);}
       var gotOutput = getOutput;
       console.log('Test result received: ' + getOutput);
    return cb(null,gotOutput);
     });
        }
    ], function asyncComplete(err, getResult) {
        if (err) {console.log(err);}
        var result = [];
        result.push({ result: getResult[0], address: getResult[1]});
        console.log(result);
    })

The error I am currently seeing when I execute the above code against testrpc, is

BigNumber Error: new BigNumber() not a base 16 number:

Any suggestions on how to get around this error?

2
  • Related and might have a helpful hint: ethereum.stackexchange.com/questions/1741/…
    – eth
    Commented Dec 5, 2016 at 0:10
  • hanks for the comment - blockchain syncing i am not sure is an issue - since i am using the testrpc and i wonder, if there could be issues around that. however, on the other hand, would you think that the issue is with type of variable being passed in - should be string instead or a bytestream of the string?
    – skarred14
    Commented Dec 5, 2016 at 1:07

1 Answer 1

4

This is a decoding bug in web3.js. I assume it has to do with the string decoding.

Please submit an issue in the web3 repo. I will look at this in the 1.0 branch

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.