2

I have the following code:

web3

    var fromAddr = u.addr;
    var contractAddr = this.addr;
    var abi = this.abi;
    var contract = web3.eth.contract(abi).at(contractAddr);
    console.log(contract.getString(x,y,{from: fromAddr, value: 0, gas: gas}));

I have also tried with variations such as

    var d = contract.getString.getData(x,y);

    var r = web3.eth.call({ to: contractAddr, data: d });

and with encoding the inputs using BigNumbers

    var input1 = web3.toBigNumber(-97);
    var input2 = web3.toBigNumber(33);  

solidity

function getString(int x, int y) 
    myModifier(msg.sender) 
    public constant returns (string) 
{        
    return string_bucket[x][y][0];
}

when I use Mist to get string_bucket[x][y] it returns correctly. When I use web3, it doesn't. The variable string_bucket is not public, does that matter since getString is public? Also, I've tried updating the ABI - no luck. myModifier is used on other functions that are correctly executed/called.

If someone could add the tags return, string, and constant I'd appreciate that.

Edit:

It seemed the modifier was coded incorrectly, I fixed it but still same problem.

Regardless, when I remove the modifier from the function to return a string, it works. It seems most likely that my function to populate the variable the modifier checks might be incorrect. The weird thing is I have tried in Mist (using the same population function) and it works but doesn't from Web3. If I find an update to this later in development will let y'all know. I will be back as removing that modifier is a temporary fix - having it there is critical to the functioning of the DAPP.

  • can you provide the code of myModifier? – Joris Bontje Jul 8 '16 at 6:47
  • Any luck with this? I'm having the same problem with Web3. Truffle returns the string though. – Gus Apr 5 '18 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.