I thought that I had an error similar to this one, that the default account was not set (I was getting method undefined errors for all methods called in my contract).I've set it both in the geth console
eth.defaultAccount = eth.accounts[0]
as well as the js code using geth:
web3 = new Web3(new Web3.providers.HttpProvider(`http://${gethServer.host}:${gethServer.port}`));
/*
Strange bug. Need to specify the account the transactions are made from.
*/
web3.eth.defaultAccount = web3.eth.accounts[0];
When calling the methods of this contract:
contract C {
uint[] numbers;
function initNumbers() {
numbers.push(1);
numbers.push(2);
}
function stateChanger(uint a) {
numbers.push(a);
}
function getNumber(uint index) returns (uint) {
if(index >= numbers.length)
return 0;
else
return numbers[index];
}
}
I get the following output in the geth console:
> c.initNumbers({from:web3.eth.accounts[0],gas:4000000000});
"0x76a1882128d64d94a7bad34e656cd83d57d2a1aefc51b99ba5893f8521a1a79e"
> c.stateChanger(3, {from:web3.eth.accounts[0],gas:400000000});
"0x1b7d5ef5d19a553af756790796a094d2ba213454ab056b7696e2f18e636d8ffc"
> c.stateChanger(4, {from:web3.eth.accounts[0],gas:400000000});
"0xd342a49323b7280e1954a9d33ac9bc457a3015768d5059801d2edf1d16585b9b"
> c.getNumber(0);
"0x31295a2a7ea20cee58e6a144039ae46b835110583b6d1b9517228627eb50999c"
> c.getNumber(1);
"0xce4dba582f37c72d58c767a2b9371a9a8ddbc1e63bc6c96eb5f61cc779168f64"
> c.getNumber(3);
"0x065bd993c4c8e86b2046a53f626619020ad550958dca955a40c839bbc9a1d0c7"
Why does geth return transaction hashes instead of integers as defined by the contract interface? Is it broken?