Given a transaction on Uniswap,
how to find out what pair is being swapped, and the amount of it? Namely, via web3.js/ethers.js
Is there relevant and sufficient information in the fields of a transction? Or will one have to make additional calls?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityYou need to decode the transaction input using UniswapV2Router abi
. Look at this part of ethers' documentation: https://docs.ethers.io/v5/api/utils/abi/interface/. Especially at the parseTransaction
method.