In the recent versions of geth
, you can use the debug.traceTransaction(txid)
call to trace your transaction.
For example, here is a transaction sending some ethers to The DAO contract:
> debug.traceTransaction("0x8e5b38db03e0941677ba65275d78fe18df999c11a7be1921831082121ae73390")
...
}, {
depth: 1,
error: "",
gas: 96943,
gasCost: 3,
memory: ["000000000000000000000000b50a06ffe68c746fee498147481767f32ce16ea4", "0000000000000000000000000000000000000000000000000000000000000013", "0000000000000000000000000000000000000000000000000000000000000060", "0000000000000000000000000000000000000000000000000000000000000001"],
op: "SWAP1",
pc: 2422,
stack: ["00000000000000000000000000000000000000000000000000000000baac5300", "0000000000000000000000000000000000000000000000000000000000000060", "0000000000000000000000000000000000000000000000000000000000000020"],
storage: {
0000000000000000000000000000000000000000000000000000000000000016: "000000000000000000000000000000000000000000096d2c34d6cb6b944ab9e8",
8913b768e65415e14d5815e774a6dc351fe0f40ad272540c08c8e6a86fa6ae77: "00000000000000000000000000000000000000000000000402bf8582bb468000",
eb8d4c8dfc1d31afefdf4361baf3da7164a6863a3e14531b2faef246b93c97bb: "000000000000000000000000000000000000000000000002ac7fae5727845554"
}
}, {
depth: 1,
error: "",
gas: 96943,
gasCost: 0,
memory: ["000000000000000000000000b50a06ffe68c746fee498147481767f32ce16ea4", "0000000000000000000000000000000000000000000000000000000000000013", "0000000000000000000000000000000000000000000000000000000000000060", "0000000000000000000000000000000000000000000000000000000000000001"],
op: "RETURN",
pc: 2423,
stack: ["00000000000000000000000000000000000000000000000000000000baac5300", "0000000000000000000000000000000000000000000000000000000000000020", "0000000000000000000000000000000000000000000000000000000000000060"],
storage: {
0000000000000000000000000000000000000000000000000000000000000016: "000000000000000000000000000000000000000000096d2c34d6cb6b944ab9e8",
8913b768e65415e14d5815e774a6dc351fe0f40ad272540c08c8e6a86fa6ae77: "00000000000000000000000000000000000000000000000402bf8582bb468000",
eb8d4c8dfc1d31afefdf4361baf3da7164a6863a3e14531b2faef246b93c97bb: "000000000000000000000000000000000000000000000002ac7fae5727845554"
}
}]
You can see the same tracing information in the VM-Trace tab in https://live.ether.camp .
EDIT: You will find more debugging functions in Management APIs, including:
You identify a block with either blockHash
, which is the hash of the block, or blockNumber
, which is the position of the block in the chain. Blocks can contain multiple transactions and are generated even if there are no transactions in them, so they should not be expected to increase in series with your transactions. blockNumber
is sometimes referred to as "height". Watch the console or log output of a node if you want to see blocks getting generated.
You can get block information with eth.getBlock()
. Pass it a block hash or block number.
You can get transaction information with eth.getTransaction()
. Pass it the transaction hash of the transaction you are interested in.
eth.getTransactionReceipt()
also expects a transaction hash.
You don't need root
for any of the purposes you mention, but if you're curious what it is, see: What is the 'root' of a transaction receipt?
Best Answer
In the contract code itself you should have already placed 'events' at each point where you wish to track state changes. Then, you would use a web3.js filter to watch for the events on your calendar (sorry, I don't have a link to that code, but it would most likely involve the use of this RPC function: https://github.com/ethereum/wiki/blob/master/JSON-RPC.md#eth_newfilter).
If you don't have events already built into your smart contract, you could pull down transactions from a block explorer such as http://etherscan.io using their API functionality, but then you would have to post process and be careful to account for in-error transactions and internal transactions.