Skip to content

[good first issue] Add 'events' subcommand for eth_getLogs with address/topic filters #4

@abhicris

Description

@abhicris

Context

The CLI can query blocks, balances, and call contracts, but has no way to fetch event logs for a given contract. arbitrum-cli events --address X is a common agent workflow — "show me all AgentDeposit.Deposited events for my wallet" — and it's a natural fit for the agent-first JSON-out ethos.

Scope

  • Add Commands::Events to the enum in src/main.rs:
    • --address <contract_addr> (required).
    • --from <block> (default: "earliest", or last-1000-blocks — your call, document it).
    • --to <block> (default: "latest").
    • --topic0 <hash> (optional — filter by event signature hash).
  • Add commands::events in src/commands.rs that calls eth_getLogs with {address, fromBlock, toBlock, topics} and emits results through output::emit.
  • Convert hex block numbers with the existing hex_to_u64 in src/rpc.rs.
  • Decorate each log with a block_number_decimal field so humans can read it.
  • Unit test: a small mock rpc_call wrapper (or wiremock) that simulates eth_getLogs and asserts the JSON shape.

Acceptance criteria

  • arbitrum-cli events --address 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 --from 250000000 returns JSON.
  • --topic0 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef (ERC-20 Transfer) filters to just transfers.
  • Human mode paginates or at least doesn't overflow the screen for 100+ logs (limit to first 20 in --human, full list in JSON).
  • README updated with an events example.

Reference: src/commands.rs::balance and src/commands.rs::token_balance for the shape; PR #2 for CI/test expectations.

Estimated effort

S (3–5 hours)

kcolbchain / Abhishek Krishna

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions