All packages
ethereum_common

ethereum_common

StreamingFast
v0.4.0/13 downloads

Package ref

ethereum-common@v0.4.0

Run package

CLI

Run filtered_events from the command line.

substreams run ethereum-common@v0.4.0 filtered_events -e mainnet --start-block -1
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

Substreams Ethereum Foundational Modules

Common Ethereum Substreams modules to extract events, calls and transactions, with block indexes to skip the blocks that cannot match.

Filtered modules

Each takes a query string as its parameter and returns only the matching items. The same query drives the block filter, so blocks without a possible match are never read.

  • filtered_events matches on event address (evt_addr:) and signature (evt_sig:)
  • filtered_calls matches on called contract (call_to:), caller (call_from:) and method signature (call_method:)
  • filtered_events_and_calls matches on either family and returns both
  • filtered_transactions matches on either family and returns the whole transaction trace of each match, receipt and calls included

Supported operators are logical or ||, logical and &&, and parentheses (). Addresses and signatures are 0x-prefixed lowercase hexadecimal.

((evt_addr:0x1234… || evt_addr:0x5678…) && evt_sig:0xdeadbeef…) || call_to:0x0101…

A query cannot combine event keys with call keys using &&. The matcher is evaluated against one log's keys, then one call's keys, so no single item carries both families and evt_sig:… && call_method:… matches nothing. Use || to match either.

Block indexes

Use one as the blockFilter of your own module to have the engine skip blocks whose keys cannot satisfy your query.

  • index_events emits evt_sig: and evt_addr:
  • index_calls emits call_to:, call_from: and call_method:
  • index_events_and_calls emits all five

Removed in v0.4.0

all_events and all_calls were removed. They materialised every event and every call of every block so that the modules above could read them, which held the same data twice and wrote it to the object store on the way through. Those modules now read the block directly and lazily, decoding only what a query matches, and emit exactly what they emitted before.

If you consumed all_events or all_calls directly, read the block in your own module, or use filtered_events / filtered_calls with a query.

Every module hash changed, so cached state from v0.3.3 and earlier is not reused.

Modules

Execution graph

7 modules
mapMain

filtered_events

`filtered_events` reads from ethereum blocks and applies a filter on the event addresses and signatures. Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `evt_addr:` and signatures by `evt_sig:`. Example: `(evt_addr:0x1234... || evt_addr:0x5678...) && evt_sig:0xdeadbeef...`

Output

sf.substreams.ethereum.v1.Events

map

filtered_calls

`filtered_calls` reads from ethereum blocks and applies a filter on the called contract, the caller and the method 4-bytes signature Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `call_to:` or `call_from:`, methods by `call_method:`. Example: `(call_to:0x1234... || call_from:0x1234...) && call_method:0xdeadbeef...`

Output

sf.substreams.ethereum.v1.Calls

map

filtered_events_and_calls

`filtered_events_and_calls` reads from ethereum blocks, then applies a filter to extract the items that interest you, based on called contract, caller, call method, event address and event signature. Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses and signatures to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `evt_addr:`, `evt_sig:`, `call_to:`, `call_from:` or `call_method:`. Example: evt_sig:0x9bb8f83800000000000000000000000000000000000000000000000000000000 || (call_method:0xa9059cbb && call_to:0xdac17f958d2ee523a2206206994597c13d831ec7)

Output

sf.substreams.ethereum.v1.EventsAndCalls

map

filtered_transactions

`filtered_transactions` reads from ethereum blocks and applies a filter on the events (addresses and signatures) as well as calls (from, to and method). Supported operators are: logical or `||`, logical and `&&` and parenthesis: `()` Addresses and signatures to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by `evt_addr:`, `evt_sig:`, `call_to:`, `call_from:` or `call_method:`. Example: `((evt_addr:0x1234... || evt_addr:0x5678...) && evt_sig:0xdeadbeef...) || call_to:0x01010101...`

Output

sf.substreams.ethereum.v1.Transactions

blockIndex

index_calls

`index_calls` sets the following keys on the block: * Call contract call_to:0x0123456789abcdef0123456789abcdef01234567 (contract address in hex, prefixed by 0x) * Caller call_from:0x0123456789abcdef0123456789abcdef01234567 (caller address in hex, prefixed by 0x) * Call method call_method:0x01234567 (4 bytes of method signature in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys

blockIndex

index_events

`index_events` sets the following keys on the block: * Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x) * Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys

blockIndex

index_events_and_calls

`index_events_and_calls` sets the following keys on the block: * Event signatures evt_sig:0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (signature in hex, prefixed by 0x) * Event address evt_addr:0x0123456789abcdef0123456789abcdef01234567 (address in hex, prefixed by 0x) * Call contract call_to:0x0123456789abcdef0123456789abcdef01234567 (contract address in hex, prefixed by 0x) * Caller call_from:0x0123456789abcdef0123456789abcdef01234567 (caller address in hex, prefixed by 0x) * Call method call_method:0x01234567 (4 bytes of method signature in hex, prefixed by 0x)

Output

sf.substreams.index.v1.Keys