4

I seem to be having a problem w/ contract code not executing when called from web3 (works when called from mist). The Eth goes to the contract, so I know it is making the call at least. I am calling the contract as such:

```

    var fromAddr = sender;
    if(typeof fromAddr == "undefined" || !fromAddr )
        return false;

    var contractAddr = this.addr;
    var abi = this.abi;
    var contract = web3.eth.contract(abi).at(contractAddr);

    ...(some vars)...

    args.push({from: fromAddr, value: parseInt(value), gasPrice: gasPrice, gas: gas});
    var callback = function(err, txhash) {
        console.log('error: ' + err);
        console.log('txhash: ' + txhash);
    }
    args.push(callback);

    web3.personal.unlockAccount(fromAddr, pw);

    contract[functionName].apply(this,args);

```

and as mentioned, it works from Mist but not web3. I have some public counters that increment correctly when using the former. Any ideas on this? I had a modifier on the solidity contract but removed it an no difference. I have also tried calling the contract like:

contract[functionName](args[0],args[1],..., { gas: ... } );

with no difference. I am running an RPC node on an AWS Linux instance.

I am running geth as such:

geth --testnet --rpc --rpcaddr="0.0.0.0" --rpccorsdomain="*" --rpcapi="db,eth,net,web3,personal,web3"

EDIT: Here is a working and non-working vmtrace

working: http://testnet.etherscan.io/vmtrace?txhash=0xfb022ae9cbf0b39f9ee1890e794226ab02737bc0ccd9ae95d87a646ecbc91744

non-working (consistently stops at step 65): http://testnet.etherscan.io/vmtrace?txhash=0x0c8447d26c90189d4fcb6cfac3a2143d7132db9b6b6b55854401b4a9be99cb28

2

If you look at the first four bytes of the transaction data, one is 0x9cd61592 and the other is 0x1e2564fb. This indicates that you are not calling the same function in both transactions. The shortness of the web3 transaction execution makes me suspect that the function signature is not matching any function in the contract, which means that your ABI definition is probably wrong.

Are you sure that you defined the ABI properly in web3?

  • You know, I had a suspicion but thought surely I was mistaken. Will check and report back, going to sleep for now. I have a feeling this is correct. – babycakes Jun 24 '16 at 4:46

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.