I am using ethersjs.
I use the following code to get data of transaction
var init = function () {
var wss = new ethers.providers.WebSocketProvider(url);
wss.getTransaction(tx).then(function (transaction) {
wss.on("pending", (tx) => {
console.log(transaction.data);
}
});
});
Which will log something similar to
0x7ff36ab50000000000000000000000000000000000000000000000bc18ba4144048bbab00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000c0c5eb43e2df059e3be6e4fb0284c283caa5991900000000000000000000000000000000000000000000000000000000614d87a80000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000008ba0619b1e7a582e0bce5bbe9843322c954c340
Which when decoded should be like below
0 amountOutMin uint256 3469769694220364004016
1 path address[] bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c
08ba0619b1e7a582e0bce5bbe9843322c954c340
2 to address c0c5eb43e2df059e3be6e4fb0284c283caa59919
3 deadline uint256 1632470952
I tried using parseTransaction
as shown here but get function not defined.
And also tried with decodeFunctionData
but got same result that decodeFunctionData is not defined.
How can I get the information from the transaction data using ethers.js?
Thanks