如何解析以太坊中uniswap的交易数据

各位大佬好,我想从uniswap的交易记录中解析出是哪两个token进行了swap。 比如这个交易https://etherscan.io/tx/0x165832e53495743460e88a60e4514a1500d4e94d3e56c121d944fc387a41cf06 我通过web3.py得到的log是这样的:

AttributeDict({'blockHash': HexBytes('0x48ecdc07f7dabb2c9f41315ca10a255ec4f8dcfc3d2e889c19156a6b1655f2e2'),
 'blockNumber': 16936885,
 'contractAddress': None,
 'cumulativeGasUsed': 129949,
 'effectiveGasPrice': 24533251455,
 'from': '0xdD8eF55055E01D39cb87571Bd38c43AB9b5903a5',
 'gasUsed': 129949,
 'logs': [AttributeDict({'address': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
   'topics': [HexBytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'),
    HexBytes('0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640'),
    HexBytes('0x000000000000000000000000f8b721bff6bf7095a0e10791ce8f998baa254fd0')],
   'data': HexBytes('0x000000000000000000000000000000000000000000000006b885e48963ccf3be'),
   'blockNumber': 16936885,
   'transactionHash': HexBytes('0x165832e53495743460e88a60e4514a1500d4e94d3e56c121d944fc387a41cf06'),
   'transactionIndex': 0,
   'blockHash': HexBytes('0x48ecdc07f7dabb2c9f41315ca10a255ec4f8dcfc3d2e889c19156a6b1655f2e2'),
   'logIndex': 0,
   'removed': False}),
  AttributeDict({'address': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
   'topics': [HexBytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'),
    HexBytes('0x000000000000000000000000f8b721bff6bf7095a0e10791ce8f998baa254fd0'),
    HexBytes('0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640')],
   'data': HexBytes('0x00000000000000000000000000000000000000000000000000000033bb60e60a'),
   'blockNumber': 16936885,
   'transactionHash': HexBytes('0x165832e53495743460e88a60e4514a1500d4e94d3e56c121d944fc387a41cf06'),
   'transactionIndex': 0,
   'blockHash': HexBytes('0x48ecdc07f7dabb2c9f41315ca10a255ec4f8dcfc3d2e889c19156a6b1655f2e2'),
   'logIndex': 1,
   'removed': False}),
  AttributeDict({'address': '0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640',
   'topics': [HexBytes('0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67'),
    HexBytes('0x000000000000000000000000f8b721bff6bf7095a0e10791ce8f998baa254fd0'),
    HexBytes('0x000000000000000000000000f8b721bff6bf7095a0e10791ce8f998baa254fd0')],
   'data': HexBytes('0x00000000000000000000000000000000000000000000000000000033bb60e60afffffffffffffffffffffffffffffffffffffffffffffff9477a1b769c330c420000000000000000000000000000000000005c4980de24e8b48b3fc0309b77140000000000000000000000000000000000000000000000019cc3b282b6cbe66600000000000000000000000000000000000000000000000000000000000312c3'),
   'blockNumber': 16936885,
   'transactionHash': HexBytes('0x165832e53495743460e88a60e4514a1500d4e94d3e56c121d944fc387a41cf06'),
   'transactionIndex': 0,
   'blockHash': HexBytes('0x48ecdc07f7dabb2c9f41315ca10a255ec4f8dcfc3d2e889c19156a6b1655f2e2'),
   'logIndex': 2,
   'removed': False})],
 'logsBloom': HexBytes('0x00000000010000000000000000000000000000000000000000000200040000000000000000000000000008000000000002000000080020000000000000000000000000000000000808000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000800000000000000000000000000000000000000000000010000000000000000000000104000000000200000000000000000000000000000000000002000000008000000000002000000000000000000000000000000000000000000000000000000000000200000000000000010000000000000000000000000000000000000000000'),
 'status': 1,
 'to': '0xf8b721bFf6Bf7095a0E10791cE8f998baa254Fd0',
 'transactionHash': HexBytes('0x165832e53495743460e88a60e4514a1500d4e94d3e56c121d944fc387a41cf06'),
 'transactionIndex': 0,
 'type': 2})

但是这个数据我不知道怎么解析得到这个信息,想和大家请教一下,谢谢。

截屏2023-04-01 18.22.46.png

请先 登录 后评论

3 个回答

Jeack
请先 登录 后评论
Elvis - 智能合约开发工程师
请先 登录 后评论
吉梦良
请先 登录 后评论
  • 3 关注
  • 0 收藏,1872 浏览
  • authenticarc 提出于 2023-04-01 18:23