I'm running truffle's default example Metacoin:
import "ConvertLib.sol";
contract MetaCoin {
mapping (address => uint) balances;
function MetaCoin() {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
return true;
}
function getBalanceInEth(address addr) returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}
function getBalance(address addr) returns(uint) {
return balances[addr];
}
}
When I run the application and send some coins, it generates the following payload:
{
"jsonrpc": "2.0",
"method": "eth_sendTransaction",
"params": [{
"from":"0x86b737b44e4b04d92ff7ee7b5604cc755e2c1124",
"to":"0xea1ab86f57e0faccca14510d883cc660d5453995",
"data":"0x90b98a11000000000000000000000000914e95d7b57c1899f0a77fb1f08a9ae02b01258200000000000000000000000000000000000000000000000000000000000000ff"
}],
"id":38
}
I've sent 255 Meta to address 0x914e95d7b57c1899f0a77fb1f08a9ae02b012582 calling sendCoin()
. Then I was trying to understand the data payload, breaking it down:
?? 0x90b98a11000000000000000000000000
address to (20 Bytes) -> 914e95d7b57c1899f0a77fb1f08a9ae02b012582
uint value (32 Bytes) -> 00000000000000000000000000000000000000000000000000000000000000ff
The first part (16 Bytes) of the data payload I assume will identify the sendCoin
method inside the deployed contract.
- If so, how?
- Do these 32 Bytes just identify the method name or can it be broken down even more?