[SOLVED] Decode transfer event log

I managed to filter out transfer events by comparing to the hash value of the transfer event signature. But now I want to decode the values I have in the logs (topic0, topic1, topic2 and data) is what I need decoded and can not manage to do it correctly.

This is an example of the log data I have that needs to be decoded so I can read the values
topic0 = from
topic1 = to
topic2 = value

"log_index":string"8"
"transaction_hash":string"0x0cefeaa02b4cebdca2035cdfbfe3cfe645b57f808b7f133f2c90b22bb486b9f8"
"transaction_index":string"1"
"address":string"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
"data":string"0x0000000000000000000000000000000000000000000000003078fbcbc032018b"
"topic0":string"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
"topic1":string"0x0000000000000000000000002e4784446a0a06df3d1a040b03e1680ee266c35a"
"topic2":string"0x0000000000000000000000000f4ee9631f4be0a63756515141281a3e2b293bbe"
"topic3":NULL
"block_timestamp":string"2022-03-26T15:18:52.000Z"
"block_number":string"14462598"
"block_hash":string"0xce09bc59e5886e870e22d2650119b6c4cafe999d4ecf604e46a533c828d2b903"

I tried this which throws an error inside the log area of the dashboard

Failed to decode output: Error: data out-of-bounds (length=0, offset=32, code=BUFFER_OVERRUN, version=abi/5.0.7)

 let decoded = web3.eth.abi.decodeLog(
      [
        {
          type: "address",
          name: "from"
        },
        {
          type: "address",
          name: "to"
        },
        {
          type: "uint256",
          name: "value"
        }
      ],
      log.data,
      [log.topic0, log.topic1, log.topic2]
    );

in this particular case, it is: from=topic1, to=topic2, value=data

1 Like