Skip to main content

Event Stream

Events on MEV-Share are distributed via an SSE endpoint. Searchers listen to this endpoint to receive a stream of new events, which contain data they can use in their bundles. Currently, the events refer to Ethereum transactions.

Quickstart

Subscribe to the stream by making an HTTP GET request on the stream endpoint. The matchmaker-ts library implements this as an asynchronous event handler.

import Matchmaker, { IPendingTransaction, IPendingBundle, StreamEvent } from '@flashbots/matchmaker-ts'

const matchmaker = Matchmaker.useEthereumMainnet(authSigner)

const txHandler = matchmaker.on(StreamEvent.Transaction, (tx: IPendingTransaction) => {
/*
Do something with the pending tx here.
*/
})

const bundleHandler = matchmaker.on(StreamEvent.Bundle, (tx: IPendingBundle) => {
/*
Do something with the pending bundle here.
*/
})

// call before your program terminates:
txHandler.close()
bundleHandler.close()
Event Data

Events currently represent pending transactions, but eventually may be expanded to support other event types. For this reason we refer to this endpoint as an event stream, rather than a transaction stream.

Event Stream Endpoints

NetworkURL
Mainnethttps://mev-share.flashbots.net
Goerlihttps://mev-share-goerli.flashbots.net

The endpoint sends an event with the message :ping every 15 seconds if no other messages were sent in the last 15 seconds.

Event Scheme

Events dispatched via the SSE endpoint are JSON-encoded objects that adhere to the following scheme:

{
hash: string,
logs?: LogParams[],
txs: Array<{
callData?: string,
functionSelector?: string,
to?: string,
}>
}
ParamType InfoDescription
hashHex-stringTransaction hash.
logsArray of JSON-encoded eventsEvent logs emitted by executing the transaction.
txsArray of JSON objectsTransactions from the event. Will only be one if event is a transaction, otherwise event is a bundle.
txs.callDataHex-stringCalldata of the transaction.
txs.functionSelectorHex-string4-byte function selector.
txs.toHex-stringTransaction recipient address.

Note that each of these properties are optional; if a field is not present, it means that the transaction sender chose not to share that information.


Now that you've started listening to transactions, you're almost ready to start searching! Read on to the next page to learn about bundles.