The contract definition of the sendCoin function is:
/* Very simple trade function */
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (coinBalanceOf[msg.sender] < amount) return false;
coinBalanceOf[msg.sender] -= amount;
coinBalanceOf[receiver] += amount;
CoinTransfer(msg.sender, receiver, amount);
return true;
}
But then, on the `geth` command line, it is invoked as:
token.sendCoin.sendTransaction(eth.accounts[1], 1000, {from: eth.accounts[0]})
First, I didn't define the `sendTransaction` function (I guess that's somehow implied in the contract deployment) and second, the signature is different. I only define a receiver addres and an ammount, but here I'm providing, in addition, a `{from: eth.accounts[0]}` block (whatever the hell that is). If I didn't know this, I would thus not be able to call my own contract. Where can I find the attributes, added after deployment, of my contract functions?
Comments
What you're seeing in the {} is the transaction object which can be set after all other explicit parameters and determines among other things who pays the gas, how much to send, etc. There is also provision to set callback functions in a sendTransaction which get called once the block is mined.
sendTransaction
is a native member ofaddress
but in this instance there looks to be a convention to invoke it on the contracts functions also. You should be able to calltoken.sendCoin(eth.account[1], 1000, {from: eth.accounts[0]})
with the same effect.