What I'd like to do is analyze all the opcodes that are executed when I call a contract, or call a function from a contract.
According to my understanding, this computation would happen on my own machine, in the EVM
, and only the result would be sent to the blockchain.
My idea is that, for this result to be calculated, the computations have to run on my local machine at some point in the following process:
var contractAbi = eth.contract([{"constant":true,"inputs":[],"name":"getPeople","outputs":[{"name":"","type":"bytes32[]"},{"name":"","type":"bytes32[]"},{"name":"","type":"uint256[]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_firstName","type":"bytes32"},{"name":"_lastName","type":"bytes32"},{"name":"_age","type":"uint256"}],"name":"addPerson","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"people","outputs":[{"name":"firstName","type":"bytes32"},{"name":"lastName","type":"bytes32"},{"name":"age","type":"uint256"}],"payable":false,"type":"function"}]);
undefined
var myContract = contractAbi.at("0xC127E3ca071892B1b471b4FC568312Fcbb737879");
undefined
var getData = myContract.addPerson.getData("S. Matthew", "English", 28);
undefined
personal.unlockAccount(eth.coinbase, 'hunter2');
web3.eth.sendTransaction({to:"0xC127E3ca071892B1b471b4FC568312Fcbb737879", from:"0xd7a9a61a480d458a1181e0563b07f944df4489a6", data: getData, gas: (270000)});
"0x0cec118d22fbd572bf25c7e4143919e608989bec7da08512f2a6f3171df3b3b8"
myContract.address
"0xC127E3ca071892B1b471b4FC568312Fcbb737879"
myContract.getPeople()
[["0x532e204d61747468657700000000000000000000000000000000000000000000"], ["0x456e676c69736800000000000000000000000000000000000000000000000000"], [28]]
myContract.getPeople().toLocaleString()
"0x532e204d61747468657700000000000000000000000000000000000000000000,0x456e676c69736800000000000000000000000000000000000000000000000000,28"
How can I observe the opcodes that are being executed as a consequence of the above sequence?
Using the ByteCode To Opcode Disassembler on Etherscan I've seen which opcodes are invoked on contract creation, but I imagine that this is different than just calling a contract or one of it's functions, since- for instance, you won't need to invoke the constructor again, etc.