Context
- geth: Geth/v1.4.18-stable/linux/go1.5.1
- solc: 0.4.6
I am writing a contract testing it on a private network with a large amount of pre-allocated gas. The following works perfectly fine:
pragma solidity ^0.4.0;
contract accountList {
address[] allowedClient;
function add(address client) returns (bool) {
allowedClient.push(client);
return true;
}
function get() constant returns (address[]) {
return allowedClient;
}
}
Addresses are well added when I call the add method. I can retrieve them calling the get method. This cost me nothing since I use the same account to call the contract and to mine the transaction (I earn more gas mining the transaction than I use to call the contract).
Issue
I run out of gas when I add a second array with the same behaviour:
pragma solidity ^0.4.0;
contract accountList {
address[] allowedClient;
address[] test;
function add(address client) returns (bool) {
allowedClient.push(client);
test.push(client);
return true;
}
function get() constant returns (address[]) {
return allowedClient;
}
}
Calling the add method make me run out of gas
contractInstance.add(coinbase, {from: coinbase}, function(error, result) {
...
}
Debug in the geth console:
> eth.getBalance(eth.accounts[0])
1.245e+21
> var t = web3.debug.traceTransaction('0x456...')
> t.structLogs[t.structLogs.length-1].error
"Out of gas"
A balance of 1.245e+21 should be enough isn't it? Which configuration can I use to avoid gas limitation on my private network?
add
method? Can you show that too? – atomh33ls Dec 8 '16 at 14:47