Use the decodeparameters function to parse the Transaction log data of Binance Chain

For example, this address: https://bscscan.com/tx/0xbbd747324e51f543fe9b8e83a71f7aded49c3fd76ea2ef38637de995851b6543#eventlog

When viewing the logs, you will find that the data is encrypted.
insert image description here
code:

 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 ));

His data structure needs you to define.

got the answer:

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

Here's how to use this function: https://web3js.readthedocs.io/en/v1.5.2/web3-eth-abi.html#decodeparameters

Guess you like

Origin blog.csdn.net/milu2003516/article/details/122505504
Recommended