图1
图2
问题描述:从一笔交易tx中,需要从tx返回的hex数据中,抽取出amountIn和amountOut,请问要怎么处理啊? 使用ethers.js
像这样:
const SwapABI = ["event Swap(address indexed sender,uint amount0In,uint amount1In,uint amount0Out,uint amount1Out,address indexed to)"];
const swapEvent = new ethers.utils.Interface(SwapABI);
swapData = swapEvent.parseLog(logs)
swapData.args.amount0In.toString()
swapData.args.amount1Out.toString()