exactInput(0xb858183f) 输入参数是一个params参数,tuple类型的,如图
该功能在合约代码 IV3SwapRouter.sol 文件中有定义,如图
目标交易哈希:0x7f4e5546584485c785d4b2068d093d5b594c3383f17d45ad5b4c1401260c443f 从muticall中解析到的0xb858183f开头的原始数据如下: 0xb858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000005f8a8d77c5fe0894de0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002be9e7cea3dedca5984780bafc599bd69add087d560001f4bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000000000000000000000
解析代码: let raw = '0xb858183f开头的原始数据' let params = web3.eth.abi.decodeParameters([ { type: 'bytes', name: 'path' }, { type: 'address', name: 'recipient' }, { type: 'uint256', name: 'amountIn' }, { type: 'uint256', name: 'amountOutMinimum' } ], raw.substr(10)) console.log(params)
打印结果 Result { '0': '0x000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000005f8a8d77c5fe0894de0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b', '1': '0x0000000000000000000000000000000000000080', '2': '2', '3': '1762424454643611899102', length: 4, path: '0x000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000005f8a8d77c5fe0894de0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b', recipient: '0x0000000000000000000000000000000000000080', amountIn: '2', amountOutMinimum: '1762424454643611899102' } 输出的结果明显是不对的。
有哪个大牛知道这个参数的详情如何用web3js解析出来?除了自己手写解析代码,因为不稳定,容易出现意外情况出错。