## 一、交易信息获取 ### 1.1 合约事件例子定义 举例,比如合约中事件如下:(以下内容均使用该事件例子) “` event Transfer(address indexed from, address indexed to, uint256 value); “` – 事件名称:Transfer – 事件的参数:address, address, uint256 – 注意:此事件的from和to参数前有indexed标记,value没有indexed标记 ### 1.2
web3调用中文文档:https://www.wenjiangs.com/doc/pr2nvcat curl 调用: eth_getTransactionReceipt 注意:getTransaction返回结果中包含input,而getTransactionReceipts返回结果中包含logs。 若input=0x则为非合约调用,否则为合约方法调用。 以合约方法function transfer(address to, uint tokens) 为例; input数据分为3个部分: 例如:a9059cbb,具体可参见:
curl -s -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xae2a33da8396a6bc40e874b0f32b9967113a3dbf071ab1290c44c62d86873d36"],"id":1}' http://127.0.0.1:8545
{ "jsonrpc": "2.0", "id": 1, "result": { "blockHash": "0xb0d0e3b6c5e59b7b3e7e16701f6d6cb0c3c93487415b03839e88b3f7a241c528", "blockNumber": "0xd19505", "contractAddress": null, "cumulativeGasUsed": "0x6c847e", "effectiveGasPrice": "0x274daee580", "from": "0xb8262c6a2dcabd92a77df1d5bd074afd07fc5829", "gasUsed": "0xa169", "logs": [ { "address": "0xdac17f958d2ee523a2206206994597c13d831ec7", "topics": [ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000b8262c6a2dcabd92a77df1d5bd074afd07fc5829", "0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7" ], "data": "0x000000000000000000000000000000000000000000000000000000016512c902", "blockNumber": "0xd19505", "transactionHash": "0xae2a33da8396a6bc40e874b0f32b9967113a3dbf071ab1290c44c62d86873d36", "transactionIndex": "0x71", "blockHash": "0xb0d0e3b6c5e59b7b3e7e16701f6d6cb0c3c93487415b03839e88b3f7a241c528", "logIndex": "0xa0", "removed": false } ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000010000000000000000000000000000000000000000000000000000000008000000000080000000000000000000000000000000000000000000000000000000000000000000200000000000000010000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000080000000000000000000000000000000000000004000000002000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000200", "status": "0x1", "to": "0xdac17f958d2ee523a2206206994597c13d831ec7", "transactionHash": "0xae2a33da8396a6bc40e874b0f32b9967113a3dbf071ab1290c44c62d86873d36", "transactionIndex": "0x71", "type": "0x2" } }
二、input解析
2.1 input内容解析
三、logs解析
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。