Skip to main content

How to Consume Execution Events in Rust: A Basic Example

This guide walks through building a minimal Rust application that reads execution events from a live Monad node. By the end of this guide, you’ll have a working event consumer that prints each EVM action as it happens.

Prerequisites

This guide assumes you have:
  • A running Monad node with execution events enabled (setup guide)

Project Setup

Here is the repo with the code. Create a new Rust project:
Replace Cargo.toml with:

The Code

Replace src/main.rs with:
src/main.rs

Build and Run

Expected Output

You’ll see a stream of events as your node processes transactions:

Key Concepts

Event Ring

The event ring is a shared memory buffer where the execution daemon writes events. Multiple readers can consume from it simultaneously, each maintaining their own position.

EventNextResult

  • Ready: An event is available to process
  • NotReady: No new events yet (daemon hasn’t written any)
  • Gap: Reader fell behind and events were overwritten - call reset() to recover

Event Types

Common events you’ll see:
  • BlockStart / BlockEnd - Block boundaries
  • TxnHeaderStart / TxnEnd - Transaction boundaries
  • TxnEvmOutput - Transaction execution result (contains receipt with gas_used)
  • TxnLog - EVM log emission (Solidity events)
  • AccountAccess - Account touched during execution
  • StorageAccess - Contract storage read/write

Next Steps