I have the following simple smart contract...
contract SimpleStorage {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}
Which I deploy with the following code in the geth console...
var source = "contract SimpleStorage...[code here]"
var compiled = web3.eth.compile.solidity(source)
var contract = web3.eth.contract(compiled.Coin.info.abiDefinition)
var storage = contract.new({from:web3.eth.accounts[0], data: compiled.SimpleStorage.code, gas: 300000})
After the contract has been mined, I am able to access the contract functions via the storage object. I assumed that I could just call...
storage.set(10)
...to set the storedData variable. However every time I try this I get an "Invalid Address" error.
I'm sure that this is because I am attempting to perform a write operation on the internal state of the contract (read operations work fine).
I need to submit a transaction that mines the new state of the contract, however I can't figure out how to do this.
How can I perform write transactions in smart contracts?