Skip to content

Decoding Ethereum Virtual Machine (EVM) log data

Posted on:2 August 2025 at 11:52

Decoding Ethereum Virtual Machine (EVM) log data from raw logs can be a complex process. This guide provides an example-first approach to deconstructing key smart contract topics.

Table of contents

Open Table of contents

Understanding EVM Log Format

EVM logs contain several key fields, including:

The first topic in the topics array is always the event topic itself. Any subsequent topics are for indexed data fields.

Decoding Log Data

1. Deconstructing Topics

Topics are 32-byte hexadecimal strings. To convert an indexed address from its padded format to a standard address format, follow these steps:

  1. Remove the 0x prefix.
  2. Take the last 20 bytes (40 characters) of the string.
  3. Add the 0x prefix back to the beginning.

For example, to convert 0x0000000000000000000000005a2020ff5a7cf0b8c73b268863f630ce4bcbf859:

2. Deconstructing Data

The data field is a single, long hexadecimal string prefixed with 0x. To decode it:

  1. Remove the 0x prefix.
  2. Split the remaining string into fixed-width 64-character slices.
  3. Convert each slice from hexadecimal to the appropriate data type (e.g. number, boolean, or string) based on the event’s structure.

For example, using the data string 0x000000000000000000000000000000000000000000000000000000000098968000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000960544:


Smart Contract Topic Examples

Here are some examples of smart contract topics and how to decode their data using the methods above.

Both indexed and non-indexed data

Only indexed data

Only non-indexed data

Example SQL Filter

This SQL query shows how to filter for these events using the topic hashes.

SELECT * FROM raw_logs
WHERE
'0x0261151a7784321c0b49e79b25a33288d9ddeb79bde1de0842c27553200bff5c' = ANY(topics) -- Buy
OR '0xd653a09379af1a9472753eadfc8952c8fac7326a1dc3060a0b146ca0de7da5c6' = ANY(topics) -- Create Market
OR '0x17e81264e9784a525cc8509a5111e7e60a77a315c8091159f7b1ae8291d6917f' = ANY(topics) -- Claim Creator Fees