Documentation Index
Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
Use this file to discover all available pages before exploring further.
Try it Live
Run EventLog examples in the interactive playground
Filter Semantics
Single Address
Checks exact address equality using constant-time comparison:
import { EventLog, Address } from 'tevm';
const usdcAddress = Address('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48');
// Filter logs from USDC contract
const usdcLogs = allLogs.filter(log => log.matchesAddress(usdcAddress));
console.log(`Found ${usdcLogs.length} USDC logs`);
Multiple Addresses (OR Logic)
Matches if log address equals ANY of the filter addresses:
import { EventLog, Address } from 'tevm';
const stablecoins = [
Address('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), // USDC
Address('0x6B175474E89094C44Da98b954EedeAC495271d0F'), // DAI
Address('0xdAC17F958D2ee523a2206206994597C13D831ec7'), // USDT
];
// Filter logs from any stablecoin
const stablecoinLogs = allLogs.filter(log =>
log.matchesAddress(stablecoins)
);
console.log(`Found ${stablecoinLogs.length} stablecoin logs`);
Usage Patterns
Filtering Single Contract
import { EventLog, Address } from 'tevm';
const wethAddress = Address('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2');
// Get all WETH logs
const wethLogs = allLogs.filter(log => log.matchesAddress(wethAddress));
// Process WETH events
for (const log of wethLogs) {
const sig = log.getTopic0();
// ... decode event
}
Multi-Contract Monitoring
import { EventLog, Address } from 'tevm';
// Monitor multiple DEX contracts
const dexContracts = [
Address('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'), // Uniswap V2
Address('0xE592427A0AEce92De3Edee1F18E0157C05861564'), // Uniswap V3
Address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), // Sushiswap
];
const dexLogs = allLogs.filter(log => log.matchesAddress(dexContracts));
console.log(`Found ${dexLogs.length} DEX logs across ${dexContracts.length} contracts`);
Token Portfolio Tracking
import { EventLog, Address } from 'tevm';
// User's token portfolio
const portfolio = [
Address('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), // USDC
Address('0x6B175474E89094C44Da98b954EedeAC495271d0F'), // DAI
Address('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), // WETH
Address('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'), // WBTC
];
// Get all events from portfolio tokens
const portfolioLogs = allLogs.filter(log => log.matchesAddress(portfolio));
// Group by contract
const byContract = new Map();
for (const log of portfolioLogs) {
const addr = Address.toHex(log.address);
if (!byContract.has(addr)) {
byContract.set(addr, []);
}
byContract.get(addr).push(log);
}
console.log('Events per token:', byContract.size);
Excluding Specific Contracts
import { EventLog, Address } from 'tevm';
const excludedContract = Address('0x...');
// Filter OUT logs from specific contract
const filtered = allLogs.filter(log => !log.matchesAddress(excludedContract));
Combining with Topic Filters
import { EventLog, Address, Hash } from 'tevm';
const TRANSFER_SIG = Hash('0xddf252ad...');
const tokens = [usdcAddress, daiAddress, wethAddress];
// Transfer events from any of these tokens
const transfers = allLogs.filter(log =>
log.matchesAddress(tokens) &&
log.matchesTopics([TRANSFER_SIG])
);
console.log(`Found ${transfers.length} transfers`);
Uses constant-time address comparison to prevent timing attacks:
import { EventLog } from 'tevm';
// Comparison time doesn't leak whether addresses match
const matches = log.matchesAddress(targetAddress);
// Safe for filtering sensitive addresses
const sensitiveAddresses = [userWallet, exchangeAddress];
const sensitiveL ogs = allLogs.filter(log =>
log.matchesAddress(sensitiveAddresses)
);
Batch Filtering
For large log arrays, use filterLogs for optimized batch filtering:
import { EventLog } from 'tevm';
// Efficient: Uses optimized internal filtering
const filtered = EventLog.filterLogs(allLogs, {
address: [usdc, dai, weth],
});
// Less efficient: Filters in JavaScript loop
const filtered2 = allLogs.filter(log =>
log.matchesAddress([usdc, dai, weth])
);
See Also