I am looking at tracking ERC-20 token swaps. For example, this transaction hash "0xbcc5eeae8313f2c958b858f7ad6998935f1e74362289571110dc0930779effea" is swapping DAI for ether.
I can see using Etherscan that it is using the function swapExactTokensForETH(). How would I determine this using web3? I can return the transaction input, but I don't know how to parse it. I tried the following based on the fields shown in Etherscan:
web3.eth.abi.decodeParameters([{
type: 'uint256',
name: 'amountIn'
},{
type: 'uint256',
name: 'amountOutMin'
},{
type: 'address[]',
name: 'path'
},{
type: 'address',
name: 'to'
},{
type: 'uint256',
name: 'deadline'
}],input));
But I get the following type of error:
Error: overflow (fault="overflow", operation="toNumber" ...
How can I programmatically parse the input value of a transaction?