Take this as an example: https://bscscan.com/tx/0x46ab3eda9ca611bbb839bab26b67425f38d577ede8fb350cc3b30b5431483acf
See the fine print? Click in, there is a library dedicated to parsing.
Parsing input strips off the first 10 characters, since that's the method's encrypted characters.
The complete code is as follows:
let input_data = `0x7ff36ab500000000000000000000000000000000000000000073ef44020e785db242c9dd000000000000000000000000000000000000000000000000000000000000008000000000000000000000000060675dbb66f2c58b5ab07cdc7b034b95c59289090000000000000000000000000000000000000000000000000000000061e1cd290000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c0000000000000000000000007fb4ed1b35d8f8638056913bece78b8cd624ca0d`;
input_data = input_data.substring(10);
const {
decodeConstructorArgs} = require('canoe-solidity');
let abiExample = {
'abi': [
{
"inputs": [
{
"internalType": "uint256", "name": "amountOutMin", "type": "uint256"},
{
"internalType": "address[]",
"name": "path",
"type": "address[]"
}, {
"internalType": "address", "name": "to", "type": "address"},
{
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
}
],
'type': 'constructor'
}
]
};
console.log(decodeConstructorArgs(abiExample.abi, input_data));
output:
[
{
name: 'amountOutMin',
type: 'uint256',
data: '140156369371873394114611677'
},
{
name: 'path',
type: 'address[]',
data: [
'bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
'7fb4ed1b35d8f8638056913bece78b8cd624ca0d'
]
},
{
name: 'to',
type: 'address',
data: '60675dbb66f2c58b5ab07cdc7b034b95c5928909'
},
{
name: 'deadline', type: 'uint256', data: '1642188073' }
]