realfun_token_stream
Package ref
realfun-token-stream@v0.5.0Run package
CLI
Run map_tokens_created from the command line.
substreams run realfun-token-stream@v0.5.0 map_tokens_created -e base_sepolia --start-block -1substreams auth or directly on thegraph.market (see docs).README
realfun_token_stream Substreams Modules
This package was initialized via substreams init, using the evm-events-calls template.
Usage
substreams build
substreams auth
substreams gui # Get streaming!
substreams registry login # Login to substreams.dev
substreams registry publish # Publish your Substreams to substreams.dev
Modules
All of these modules produce data filtered by these contracts:
- Factory at 0x39e93ce835fbe020a51da32c2e5fec2580703c2e
- Pair contracts created from the factory
store_pairs
This module listens for MemeTokenCreated events emitted by the factory contract and stores the addresses of the created token pairs. These stored pair addresses are later used to filter buy and sell events.
Output: Stores pair addresses in a persistent store.
map_tokens_created
This module captures all MemeTokenCreated events from the factory contract. It extracts details about the created tokens, such as their address, name, symbol, image URL, and description.
Output:
token_addresspair_addresscreatornamesymbolimage_urldescription
map_buy_sell_events
This module processes buy and sell events (TokensPurchased and TokensSold) from the token pairs created by the factory. It matches events to the tracked pairs and classifies them as "buy" or "sell" transactions.
Output:
event_type: "buy" or "sell"user: Address of the buyer or sellereth_amount: ETH spent or receivedtoken_amount: Tokens purchased or soldcurrent_price: Current token pricetotal_supply: Total token supplycirculating_supply: Circulating token supplyeth_reserve: ETH reserve in the pool
map_king_of_the_hill
This module identifies the token with the highest market cap from the processed TokensPurchased events. Market cap is calculated as:
Market Cap = current_price * circulating_supply
Output:
king_bonding_pair: Address of the top token's pairmarket_cap: Highest market cap value
map_price_bars
This module generates OHLC (Open, High, Low, Close) price data, also known as "price bars," from the token buy and sell events. It aggregates price and volume data over specified intervals (default is 1 minute).
Output:
mint: Token identifiertimestamp: Time of the price baropen: Opening pricehigh: Highest price during the intervallow: Lowest price during the intervalclose: Closing pricevolume: Total traded volumeslot: Block slot numberis_1_min: Indicates if the interval is 1 minuteis_5_min: Indicates if the interval is 5 minutes
Event Handling
We implemented the Event trait for the following Ethereum events:
MemeTokenCreatedTokensPurchasedTokensSold
These events are processed by the modules to extract, store, and analyze data for meme tokens and related transactions.
Running the Substreams
Running Without Backprocessing
To run the Substreams starting from the latest block or a specific block (without backprocessing), use the following commands:
# Run from the module's initial block
substreams run ./realfun-token-stream-v0.1.0.spkg map_tokens_created \
--start-block=21711925
# Run from the latest block (if supported)
substreams run ./realfun-token-stream-v0.1.0.spkg map_tokens_created \
--start-block=now
Running Other Modules
# Run the buy/sell events module
substreams run ./realfun-token-stream-v0.1.0.spkg map_buy_sell_events \
--start-block=21711925
# Run the King of the Hill module
substreams run ./realfun-token-stream-v0.1.0.spkg map_king_of_the_hill \
--start-block=21711925
# Run the price bars module
substreams run ./realfun-token-stream-v0.1.0.spkg map_price_bars \
--start-block=21711925
GUI Interaction
To visualize and interact with the data via GUI:
substreams gui --start-block=21711925
Ensure you have authenticated and configured your .substreams.env with the correct SUBSTREAMS_API_TOKEN before running these commands.
Modules
Execution graph
Output
contract.v1.DebugOutputOutput
contract.v1.TransactionsInputs
Output
contract.v1.KingStatusOutput
Output
contract.v1.PriceBars
Inputs
Store value
string
Update policy
set
Show 9 dependencies
Output
sf.substreams.ethereum.v1.Calls
Output
sf.substreams.ethereum.v1.Events
`filtered_calls` reads from `all_calls` 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
Inputs
`filtered_events` reads from `all_events` 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
Inputs
`filtered_events_and_calls` reads from `all_calls` and `all_events`, 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
Inputs
`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
Inputs
`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
Inputs
`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
Inputs
`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