Go-Ethereum
有沒有辦法像 Etherscan 一樣分析合約交易跟踪結果?
這個問題是下面問題的延續..!
當 tracsaction 的輸入由多個合約組成時如何解碼?
在上面的問題中,需要節點資訊來跟踪合約交易,所以我
trace_transaction
在積累存檔數據的同時用目前的奇偶校驗進行測試。 https://openethereum.github.io/JSONRPC-trace-module#trace_transaction我嘗試了下面的 tx,
https://etherscan.io/tx/0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53
我得到了以下結果,但我不知道如何解釋這個……
**在使用 parity 或 geth 跟踪合約 tx 時,我如何才能像 etherscan 一樣乾淨地獲取數據?T^T
我怎樣才能像下面這樣跟踪契約?**
跟踪交易:
{ "jsonrpc": "2.0", "result": [ { "action": { "callType": "call", "from": "0xb148de08dbe19421c618b99d3a9a4e21ea1e0605", "gas": "0x299eb", "input": "0x7ff36ab5000000000000000000000000000000000000000000000000000000000009703c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e0605000000000000000000000000000000000000000000000000000000005fed87220000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000056fd409e1d7a124bd7017459dfea2f387b6d5cd", "to": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d", "value": "0x75f610f70ed20000" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x24b3e", "output": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000075f610f70ed200000000000000000000000000000000000000000000000000000000000000097c51" }, "subtraces": 4, "traceAddress": [], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "staticcall", "from": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d", "gas": "0x2820b", "input": "0x0902f1ac", "to": "0x61247d8aca1c485a50728e1336d9b26c8339e701", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x4b4", "output": "0x000000000000000000000000000000000000000000000000000000000404259d00000000000000000000000000000000000000000000003155da84a83edca37a000000000000000000000000000000000000000000000000000000005fed042b" }, "subtraces": 0, "traceAddress": [ 0 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d", "gas": "0x2594a", "input": "0xd0e30db0", "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0x75f610f70ed20000" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x5892", "output": "0x" }, "subtraces": 0, "traceAddress": [ 1 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d", "gas": "0x1f8c1", "input": "0xa9059cbb00000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e70100000000000000000000000000000000000000000000000075f610f70ed20000", "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x2ad2", "output": "0x0000000000000000000000000000000000000000000000000000000000000001" }, "subtraces": 0, "traceAddress": [ 2 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d", "gas": "0x1c1fe", "input": "0x022c0d9f0000000000000000000000000000000000000000000000000000000000097c510000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e060500000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000", "to": "0x61247d8aca1c485a50728e1336d9b26c8339e701", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x178ad", "output": "0x" }, "subtraces": 3, "traceAddress": [ 3 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x61247d8aca1c485a50728e1336d9b26c8339e701", "gas": "0x19312", "input": "0xa9059cbb000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e06050000000000000000000000000000000000000000000000000000000000097c51", "to": "0x056fd409e1d7a124bd7017459dfea2f387b6d5cd", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0xbe2e", "output": "0x0000000000000000000000000000000000000000000000000000000000000001" }, "subtraces": 1, "traceAddress": [ 3, 0 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x056fd409e1d7a124bd7017459dfea2f387b6d5cd", "gas": "0x1806b", "input": "0xdfe0f0ca00000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e06050000000000000000000000000000000000000000000000000000000000097c51", "to": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0xb137", "output": "0x0000000000000000000000000000000000000000000000000000000000000001" }, "subtraces": 4, "traceAddress": [ 3, 0, 0 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "gas": "0x169e6", "input": "0x27e235e300000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701", "to": "0xc42b14e49744538e3c239f8ae48a1eaaf35e68a0", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x4a2", "output": "0x000000000000000000000000000000000000000000000000000000000404259d" }, "subtraces": 0, "traceAddress": [ 3, 0, 0, 0 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "gas": "0x15b41", "input": "0xe30443bc00000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e7010000000000000000000000000000000000000000000000000000000003faa94c", "to": "0xc42b14e49744538e3c239f8ae48a1eaaf35e68a0", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x19b3", "output": "0x" }, "subtraces": 0, "traceAddress": [ 3, 0, 0, 1 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "gas": "0x13812", "input": "0x21e5383a000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e06050000000000000000000000000000000000000000000000000000000000097c51", "to": "0xc42b14e49744538e3c239f8ae48a1eaaf35e68a0", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x5672", "output": "0x" }, "subtraces": 0, "traceAddress": [ 3, 0, 0, 2 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "gas": "0xd8f1", "input": "0x23de665100000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e06050000000000000000000000000000000000000000000000000000000000097c51", "to": "0x056fd409e1d7a124bd7017459dfea2f387b6d5cd", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0xccb", "output": "0x" }, "subtraces": 0, "traceAddress": [ 3, 0, 0, 3 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "staticcall", "from": "0x61247d8aca1c485a50728e1336d9b26c8339e701", "gas": "0xd0d2", "input": "0x70a0823100000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701", "to": "0x056fd409e1d7a124bd7017459dfea2f387b6d5cd", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x1d3e", "output": "0x0000000000000000000000000000000000000000000000000000000003faa94c" }, "subtraces": 1, "traceAddress": [ 3, 1 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x056fd409e1d7a124bd7017459dfea2f387b6d5cd", "gas": "0xc1b2", "input": "0x70a0823100000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701", "to": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x10cf", "output": "0x0000000000000000000000000000000000000000000000000000000003faa94c" }, "subtraces": 1, "traceAddress": [ 3, 1, 0 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "call", "from": "0x6704ba24b8640bccee6bf2fd276a6a1b8edf4ade", "gas": "0xb310", "input": "0x27e235e300000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701", "to": "0xc42b14e49744538e3c239f8ae48a1eaaf35e68a0", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x4a2", "output": "0x0000000000000000000000000000000000000000000000000000000003faa94c" }, "subtraces": 0, "traceAddress": [ 3, 1, 0, 0 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" }, { "action": { "callType": "staticcall", "from": "0x61247d8aca1c485a50728e1336d9b26c8339e701", "gas": "0xadd6", "input": "0x70a0823100000000000000000000000061247d8aca1c485a50728e1336d9b26c8339e701", "to": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "value": "0x0" }, "blockHash": "0x234656aec698980f2ed0b84ab411731b705779f67da8fafd8d1661e2c85178f5", "blockNumber": 11560625, "result": { "gasUsed": "0x4d2", "output": "0x000000000000000000000000000000000000000000000031cbd0959f4daea37a" }, "subtraces": 0, "traceAddress": [ 3, 2 ], "transactionHash": "0x1118423fb0529b074551574593cb8f60d868cb81a07512ad34ea66e7cef74c53", "transactionPosition": 200, "type": "call" } ], "id": 1 }
etherscan 輸入數據:
Function: swapExactETHForTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) MethodID: 0x7ff36ab5 [0]: 000000000000000000000000000000000000000000000000000000000009703c [1]: 0000000000000000000000000000000000000000000000000000000000000080 [2]: 000000000000000000000000b148de08dbe19421c618b99d3a9a4e21ea1e0605 [3]: 000000000000000000000000000000000000000000000000000000005fed8722 [4]: 0000000000000000000000000000000000000000000000000000000000000002 [5]: 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 [6]: 000000000000000000000000056fd409e1d7a124bd7017459dfea2f387b6d5cd
你所擁有的是解決方案的一部分。您還必須查看該交易中的事件。因此 eth_getTransactionReceipt 將返回日誌(以及其他對您有用的數據。)。也看看 eth_getTransactionByHash
主題 0 是事件簽名。
Truffle Plugin Debugger(以前稱為Truffle Teams)可以提供幫助:https ://github.com/trufflesuite/truffle-plugin-debugger