user@Kumquat:~$ echo "var cSource='`stripCrLf C.sol`'" var cSource='contract C { uint[] public numbers; function initNumbers() { numbers.push(1); numbers.push(2); } function stateChanger(uint a) { numbers.push(a); } }'
user@Kumquat:~$ geth --datadir ~/devdata --dev --mine --minerthreads 1 --unlock 0 --password ~/passwordfile console
> var cCompiled = web3.eth.compile.solidity(cSource); Version: 0.3.5-0/RelWithDebInfo-Linux/g++/Interpreter path: /usr/bin/solc undefined
> cCompiled.C.info.abiDefinition [{ constant: false, inputs: [], name: "initNumbers", outputs: [], type: "function" }, { constant: false, inputs: [{ name: "a", type: "uint256" }], name: "stateChanger", outputs: [], type: "function" }, { constant: true, inputs: [{ name: "", type: "uint256" }], name: "numbers", outputs: [{ name: "", type: "uint256" }], type: "function" }]
> var cContract = web3.eth.contract(cCompiled.C.info.abiDefinition); undefined > var c = cContract.new({ from:web3.eth.accounts[0], data: cCompiled.C.code, gas: 400000}, function(e, contract) { if (!e) { if (!contract.address) { console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); } else { console.log("Contract mined! Address: " + contract.address); console.log(contract); } } }) Contract mined! Address: 0x672807a8c0f72a52d759942e86cfe33264e73934
> c.initNumbers({from:eth.accounts[0], gas: 400000}) "0x3f21e1cdb636a2cf291cd9296282a4e9c4f4ed57c65a13fedc937a97203c3a75" ... > c.numbers(0) 1 > c.numbers(1) 2 > c.numbers(2) 0
> c.stateChanger(3, {from:eth.accounts[0], gas: 400000}) "0x3ecf3aa6464f93d5b062ad01b76b5dbc4302c190baf70d157a4d7607d4c7c749" ... > c.numbers(2) 3 > c.numbers(3) 0