3

I have two simple constant functions in a contract:

function fun1 (address A) constant returns (uint) {
    return mappingAS[A].length;
}

function fun2 (address A, uint V) constant returns (string, uint) {
    return (mappingAS[A][V], mappingBE[mappingAS[A][V]][(mappingBE[mappingAS[A][V]].length)-1].timeStamp);
}

(Note: the first returns a length of an array (from mapping "address => string[]") and the other one returns values from an exact position in another array (which is as well stored in a mapping "string[] => struct[]")

Now both of these constant functions seem to work in the Mist GUI (contract watch) but if I try to call them through web3:

contractA.fun1(address).call()

contractA.fun2(address, position).call()

I still have to sign those calls as transactions (with password) and a transaction hash gets returned instead.

Contract and ABI are correctly assigned:

var contractA = web3.eth.contract(contractABI).at(contractAddress)

I'm using standard Mist's geth parameters. Should I somehow change the parameters of geth?

Thanks for any hints.

  • 2
    The syntax is contractA.fun2.call(address, position). Did you try that? – eth Sep 5 '16 at 8:16
3

The correct syntax is:

contractA.fun1.call(address)

contractA.fun2.call(address, position)

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.