-
Notifications
You must be signed in to change notification settings - Fork 8
Pending transaction subscription (newPendingTransactions full tx) #14
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededl2L2 chain supportL2 chain supportmevMEV/searcher toolingMEV/searcher tooling
Description
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_subscribewith"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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededl2L2 chain supportL2 chain supportmevMEV/searcher toolingMEV/searcher tooling