使用 decodeparameters 函数 解析币安链的 Transaction 日志数据

比如这个地址: https://bscscan.com/tx/0xbbd747324e51f543fe9b8e83a71f7aded49c3fd76ea2ef38637de995851b6543#eventlog

查看日志的时候,你会发现数据是加密的。
在这里插入图片描述
代码:

 let ss1 = `0x00000000000000000000000000000000000000000000000093845de66b9a30fe000000000000000000000000000000000000000000000000000e35fa931a00000000000000000000000000000000000000000000000000330ca85aa35d0afe280000000000000000000000000000000000000000000000000000000000000000`;

        console.log('web3', web3.eth.abi.decodeParameters([{
            type: 'uint256',
            name: 'amount0In'
        },{
            type: 'uint256',
            name: 'amount1In'
        },{
            type: 'uint256',
            name: 'amount0Out'
        },{
            type: 'uint256',
            name: 'amount1Out'
        }], ss1 ));

他这个数据结构需要你去定义。

得到结果:

web3 Result {
  '0': '10629724264730341630',
  '1': '4000000000000000',
  '2': '941696026341416828456',
  '3': '0',
  __length__: 4,
  amount0In: '10629724264730341630',
  amount1In: '4000000000000000',
  amount0Out: '941696026341416828456',
  amount1Out: '0'
}

这里有这个函数的使用方法: https://web3js.readthedocs.io/en/v1.5.2/web3-eth-abi.html#decodeparameters

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值