I am trying to parse uniswap transaction and extract "summary" like what Etherscan does when showing transaction (like this one) below:

Transaction Action:
Swap 2,937.943845 USDC For 1.055626826417338071 Ether On Uniswap V3
Swap 1.055626826417338071 Ether For 73.765903190964302924 TORN On Uniswap V3

The raw transaction data looks like this:

    "blockHash": "0x4de7a163e436e0085772da19f837e3cd7ac4c976f0acefcf41195a5262d004ee",
    "blockNumber": 14237558,
    "from": "0xd26BaA5F41CC7839CEdb020b6d98E1C6e1642D75",
    "gas": 272371,
    "gasPrice": "61850376427",
    "maxFeePerGas": "79333124379",
    "maxPriorityFeePerGas": "1500000000",
    "hash": "0xd72a4edd39a45a65055a7b9b8a1c772c21012801be195ef529f2f96bdbbdf6a8",
    "input": "0x5ae401dc00000000000000000000000000000000000000000000000000000000621123160000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000124b858183f00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000d26baa5f41cc7839cedb020b6d98e1c6e1642d7500000000000000000000000000000000000000000000000000000000af1d7725000000000000000000000000000000000000000000000003f3ce7f66bc562ee70000000000000000000000000000000000000000000000000000000000000042a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200271077777feddddffc19ff86db637967013e6c6a116c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "nonce": 53,
    "to": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
    "transactionIndex": 44,
    "value": "0",
    "type": 2,
    "chainId": "0x1",
    "v": "0x0",
    "r": "0x3a00df8025b591167bf0f05fce01a84e79260dea7d5d3720a2a6d795383f1fe4",
    "s": "0x6db1374f2058e222b73419dd9b3974dad1d6c9d5478dc9ac09a9f2943a0947a3"

I am assuming that the transaction summary can be extracted from the input attribute, but unsure how to do that.

  • You have to analyze the log entries in the transaction's receipt.
    – Ismael
    Commented Feb 20, 2022 at 4:20

1 Answer 1


After some more digging, I found out this article, which explained how to get some data out of the input attribute of the transaction (no transaction logs required). See below the function that takes a transaction hash and outputs from and to tokens (other data is also available in the input). Note, that amountOutMin doesn't give you exact data about how much token will be received, but it was enough in my case.

I use abi-decoder library to decode input data. ABI itself is downloaded from ethernet GetABI API.

Also, getTokenSymbol function in the code just calls .symbol() API of the ERC20 contract to get token symbol.

async function processTransaction(transactionHash) {
  let transaction = await web3.eth.getTransaction(transactionHash);

  const data = abiDecoder.decodeMethod(transaction.input);
  const paths = data.params.filter((param) => param.name === "path")[0].value;
  const fromToken = paths[0];
  const toToken = paths.slice(-1)[0];
  const amountIn = data.params.filter((param) => param.name === "amountIn")[0]
  const amountOutMin = data.params.filter(
    (param) => param.name === "amountOutMin"
  const fromTokenSymbol = await getTokenSymbol(fromToken);
  const toTokenSymbol = await getTokenSymbol(toToken);
    `Exchanged ${amountIn} of ${fromTokenSymbol} to at least ${amountOutMin} ${toTokenSymbol}`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.