Skip to content

Adds eth-client@1.0 device #637

Open
Lucifer0x17 wants to merge 14 commits intoedgefrom
feat/lido-oracle
Open

Adds eth-client@1.0 device #637
Lucifer0x17 wants to merge 14 commits intoedgefrom
feat/lido-oracle

Conversation

@Lucifer0x17
Copy link

Adds a new device, eth-events@1.0, to fetch Ethereum contract event logs.

This device is RPC-provider agnostic and supports multiple event signatures, as well as different modes for fetching logs (latest-only, incremental, rolling-window, range).

Also, this change allows scheduling of base message in ~scheduler@1.0.

Lucifer0x17 and others added 3 commits February 9, 2026 22:05
Add a stateless, RPC-provider-agnostic device that speaks standard
   Ethereum JSON-RPC (eth_blockNumber, eth_getLogs) to fetch and decode
   contract event logs. Works with Alchemy, Moralis, Infura, QuikNode,
   or any compliant endpoint.

   Key design decisions:

   - Stateless: every request is self-contained (RPC URL, contract,
     event signature, mode). No session state or configure step.
   - Uses relay@1.0 internally for all HTTP calls to RPC providers.
   - Supports four block-range modes:
     - latest-only: single latest block (default)
     - incremental: resume from last-block with configurable offset
     - rolling-window: sliding N-block window behind chain head
     - range: explicit from-block/to-block
   - Full ABI event decoding when event-signature is provided:
     indexed params decoded from topics, non-indexed from data field.
     Supports address, uint*, int* (with two's complement), bool types.
   - Raw mode (raw=true) returns events as-is from RPC.
   - Integer values always returned as binary strings to avoid
     serialization overflow on large uint256 values.

   Internal structure:
   - parse_params/2: normalizes all request params once upfront
   - rpc/4: centralized JSON-RPC call + response parsing wrapper
   - calculate_block_range/4: pure block arithmetic per mode
   - event_metadata/1: shared metadata extraction for all decode paths

   Includes unit tests for block range calculation, JSON-RPC response
   parsing, ABI value decoding, and full Transfer event decoding.

   Registered as eth-events@1.0 in hb_opts.erl preloaded_devices.
@Lucifer0x17 Lucifer0x17 self-assigned this Feb 11, 2026
Lucifer0x17 and others added 8 commits February 11, 2026 16:43
… log queries

Implements a general-purpose Ethereum client device with three keys:
  - rpc: raw JSON-RPC proxy (eth_blockNumber, etc.)
  - call: ABI-encoded eth_call with automatic encoding/decoding
  - get-data: event log fetching with incremental, range, and block modes

  Includes ABI encoding/decoding for common Solidity types (uint, address,
  string, bytes, bool, tuples), keccak256 topic hashing, multi-event
  signature support, and safe block resolution (head - 40 finality offset).
@Lucifer0x17
Copy link
Author

eth-client@1.0 Device

A stateless, RPC-provider agnostic device for interacting with Ethereum from HyperBEAM. Every request is self-contained, the caller passes all parameters. Works with any standard Ethereum JSON-RPC endpoint

The device exports three keys:

  • rpc: Raw JSON-RPC Passthrough
    => Executes any eth_* method directly.
    => Required params: rpc-url, rpc-method
    => Optional: rpc-params (JSON array, default [])

Response: { body: { data: }, status: 200 }

Examples:

  • Get current block
curl 'http://localhost:8734/~eth-client@1.0/rpc&rpc-url="https://eth.merkle.io"&rpc-method=eth_blockNumber'
  • Get transaction count for an address
curl 'http://localhost:8734/~eth-client@1.0/rpc&rpc-url="https://eth.merkle.io"&rpc-method=eth_getTransactionCount&rpc-params=["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","latest"]'

  • call: Read-Only Contract Calls (eth_call)
    => Executes read-only contract functions with automatic ABI encoding/decoding
    => Required params: rpc-url, to (contract address), function (Solidity signature)
    => Optional: args (comma-separated), returns (return type for decoding), block (default "latest"), from, value, gas
    => Supported ABI types: uint256, int256, address, bool, string, bytes, bytes32

Response: { body: { data: , raw: , block: , block-number: }, status: 200 }

Examples:

  • Read totalSupply from stETH
curl 'http://localhost:8734/~eth-client@1.0/call&rpc-url="https://eth.merkle.io"&to=0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84&function=totalSupply()&returns=uint256'
  • Call with arguments
curl 'http://localhost:8734/~eth-client@1.0/call&rpc-url="https://eth.merkle.io"&to=0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84&function=balanceOf(address)&args=0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045&returns=uint256'

  • get-data: Event Log Fetching (eth_getLogs)
    => Fetches and decodes contract event logs with flexible block range modes.
    => Required params: rpc-url, contract
    => Optional: event-signature, mode, raw (skip decoding)
    => Supports multiple event signatures comma-separated: UserStaked(address,uint256),UserWithdrawn(address,uint256)
    => Modes
    • latest-only (default)
      => Fetches logs from the current head block only.
      => No extra params needed.

    • incremental
      => Fetches logs from last-block + 1 to head - offset (safe block).
      => If no last-block provided, starts from the safe block itself.
      => Optional: last-block (hex or int), block-offset (default 40)

    • range
      => Fetches logs in an explicit block range.
      => Required: from-block, to-block (hex or int)

    • rolling-window
      => Fetches logs from head - window to head.
      => Optional: block-window (default 40)

Response: { body: { data: , from-block, from-block-number, to-block, to-block-number, latest-block, latest-block-number, contract }, status: 200 }

Examples:

  • Fetch decoded events in a block range
curl 'http://localhost:8734/~eth-client@1.0/get-data&rpc-url="https://eth.merkle.io"&contract=0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84&event-signature=TokenRebased(uint256,uint256,uint256,uint256,uint256,uint256,uint25
6)&mode=range&from-block=20081157&to-block=20081200'
  • Fetch multiple event types in single request
curl 'http://localhost:8734/~eth-client@1.0/get-data&rpc-url="https://eth.merkle.io"&contract=0xfE08D40Eee53d64936D3128838867c867602665c&event-signature=UserStaked(uint256,address,uint256,bytes32),UserWithdrawn(uint256,a
ddress,uint256,bytes32)&mode=range&from-block=20081157&to-block=20083000'

Authentication

  • For RPC providers that require API keys:
curl 'http://localhost:8734/~eth-client@1.0/rpc&rpc-url="https://eth-mainnet.g.alchemy.com/v2"&api-key=YOUR_KEY&api-key-header=x-api-key&rpc-method=eth_blockNumber'
  • api-key: The API key value
  • api-key-header: Header name to send it in (default: x-api-key)

@Lucifer0x17 Lucifer0x17 added the enhancement New feature or request label Feb 14, 2026
@Lucifer0x17 Lucifer0x17 changed the title Adds eth-events@1.0 device for event log retrieval Adds eth-client@1.0 device Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants