This package was initialized via substreams init
, using the evm-minimal
template.
This substream monitors blockchain transactions in real-time, specifically designed to track incoming transactions to specified addresses. It supports both native ETH transfers and ERC20 token transfers.
from
and to
addressesThis substream includes advanced block filtering that dramatically reduces data consumption and processing time. Instead of processing all blocks, it only processes blocks that contain:
# Monitor incoming transactions to a specific address
python generate_block_filter.py --to 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6
# Monitor outgoing transactions from a specific address
python generate_block_filter.py --from 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6
# Monitor both incoming and outgoing for an address
python generate_block_filter.py --to 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6 --from 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6
# Dry run to see the generated query without updating files
python generate_block_filter.py --to 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6 --dry-run
After running the block filter generator:
# Rebuild the substream with optimizations
make build
# Run with optimized filtering
./run_live.sh --to 0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6
The block filter uses the eth_common:index_events
module to pre-filter blocks based on:
evt_sig:0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
tx_to:{address}
and tx_from:{address}
This ensures your substream only processes blocks that contain relevant transactions, dramatically reducing the data stream from potentially hundreds of MB per block to just the relevant transactions.
For live monitoring of incoming transactions:
# Make the script executable (first time only)
chmod +x run_live.sh
# Start live monitoring
./run_live.sh
Note: When no start block is specified, the substream automatically starts from the current head of the blockchain and continues monitoring new blocks as they arrive. This ensures you're always monitoring the latest transactions without processing historical data.
# Build the project
cargo build --target wasm32-unknown-unknown --release
# Authenticate with Substreams
substreams auth
# Run in live mode (starts from current head and continues monitoring new blocks)
substreams run substreams.yaml filter_transactions --log-level=info
To process historical blocks:
# Process from a specific block number
substreams run substreams.yaml filter_transactions --start-block 1000000
# Process a range of blocks
substreams run substreams.yaml filter_transactions --start-block 1000000 --stop-block 1000100
You can configure the addresses to monitor in two ways:
substreams.yaml
)Configure the addresses to monitor in substreams.yaml
:
params:
filter_transactions: 'to=0xcccd218a58b53c67fc17d8c87cb90d83614e35fd'
You can also filter by multiple addresses:
params:
filter_transactions: 'to=0xcccd218a58b53c67fc17d8c87cb90d83614e35fd&from=0x1234567890123456789012345678901234567890'
The run_live.sh
script supports command line parameters for flexible configuration:
# Monitor transactions to a specific address
./run_live.sh --to 0x1234567890123456789012345678901234567890
# Monitor transactions from a specific address
./run_live.sh --from 0xabcdefabcdefabcdefabcdefabcdefabcdefabcd
# Monitor transactions between two addresses
./run_live.sh --to 0x1234567890123456789012345678901234567890 --from 0xabcdefabcdefabcdefabcdefabcdefabcdefabcd
# Use custom parameters string
./run_live.sh --params 'to=0x1234567890123456789012345678901234567890&from=0xabcdefabcdefabcdefabcdefabcdefabcdefabcd'
# Monitor on different networks
./run_live.sh --network mainnet.streamingfast.io:443 --to 0x1234567890123456789012345678901234567890
./run_live.sh --network polygon-mainnet.streamingfast.io:443 --to 0x1234567890123456789012345678901234567890
# Use default parameters from substreams.yaml
./run_live.sh
You can also pass parameters directly to the substreams command:
# Build the project first
cargo build --target wasm32-unknown-unknown --release
# Run with custom parameters
substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml filter_transactions \
--params filter_transactions='to=0x1234567890123456789012345678901234567890' \
--start-block 1000000 \
--limit-processed-blocks 0
# Run on different networks
substreams run -e mainnet.streamingfast.io:443 substreams.yaml filter_transactions \
--params filter_transactions='to=0x1234567890123456789012345678901234567890' \
--start-block 1000000 \
--limit-processed-blocks 0
to
: Monitor incoming transactions to this address (supports both direct transfers and ERC20 transfers)from
: Monitor outgoing transactions from this addressbase-mainnet.streamingfast.io:443
(default) - Base networkmainnet.streamingfast.io:443
- Ethereum mainnetpolygon-mainnet.streamingfast.io:443
- Polygon networkParameters use URL query string format:
to=0x1234567890123456789012345678901234567890
to=0x1234567890123456789012345678901234567890&from=0xabcdefabcdefabcdefabcdefabcdefabcdefabcd
to=0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd
See ./examples.sh
for a comprehensive list of usage examples.
The substream outputs transaction data in the following format:
{
"transactions": [
{
"from": "0x...",
"to": "0x...",
"hash": "0x...",
"value": "1000000000000000000",
"token_id": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
}
]
}
token_id
will be 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
token_id
will be the contract address of the tokenOptionally, you can publish your Substreams to the Substreams Registry.
substreams registry login # Login to substreams.dev
substreams registry publish # Publish your Substreams to substreams.dev
block_filter
(New)This module pre-filters blocks to only include those with relevant transactions:
This dramatically reduces data consumption and processing time.
filter_transactions
This module filters and processes blockchain transactions based on specified address filters. It:
Key dependencies:
substreams
: Core Substreams frameworksubstreams-ethereum
: Ethereum-specific functionalitynum-bigint
: Big integer arithmetic for token amountsserde
: Serialization/deserializationanyhow
: Error handlingfilter_transactions
returns full transaction data from the block with comprehensive logging.
This module continuously processes all blocks to monitor for incoming transactions to specified addresses.
substreams gui cypher-substreams@v0.1.4 filter_transactions