Summary
Add support for subscribing to full pending transactions via WebSocket (eth_subscribe with newPendingTransactions and full: true).
Motivation
MEV bots need to see pending transactions as they enter the mempool to identify opportunities (sandwich, backrun, liquidation). The current WebSocket subscription support needs to include full transaction objects -- not just hashes -- to avoid an extra eth_getTransactionByHash round-trip per pending tx.
On L2s, pending transaction visibility varies by chain, but where available, it's the primary signal for searchers.
Proposed API
const eth = @import("eth");
var ws = eth.ws_transport.WsTransport.init(allocator, "wss://eth.llamarpc.com");
defer ws.deinit();
// Subscribe to full pending transactions
var sub = try ws.subscribePendingTransactions(.{ .full = true });
while (try sub.next()) |tx| {
// tx is a full Transaction object
if (isTargetSwap(tx.data)) {
// Found a DEX swap in the mempool
const opportunity = evaluateArb(tx);
// ...
}
}
Implementation Notes
- Uses
eth_subscribe with "newPendingTransactions" and {"includeTransactions": true} parameter
- Parse the full transaction object from the subscription notification
- Should integrate with the existing WebSocket transport in
src/ws_transport.zig
- Consider a filtered variant that only returns txs matching certain criteria (to/from address, value threshold) to reduce parsing overhead
References
Summary
Add support for subscribing to full pending transactions via WebSocket (
eth_subscribewithnewPendingTransactionsandfull: true).Motivation
MEV bots need to see pending transactions as they enter the mempool to identify opportunities (sandwich, backrun, liquidation). The current WebSocket subscription support needs to include full transaction objects -- not just hashes -- to avoid an extra
eth_getTransactionByHashround-trip per pending tx.On L2s, pending transaction visibility varies by chain, but where available, it's the primary signal for searchers.
Proposed API
Implementation Notes
eth_subscribewith"newPendingTransactions"and{"includeTransactions": true}parametersrc/ws_transport.zigReferences