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.
- matchmaker-ts
- curl
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()
curl https://mev-share-goerli.flashbots.net
This will block until terminated manually (CTRL-C).
Response:
:ping
data: {"hash":"0xc7dc06c994400830054ab815732d91275bc1241f9be62b62b687b7882f19b8d4","logs":null,"txs":[{"to":"0x0000c335bc9d5d1af0402cad63fa7f258363d71a","functionSelector":"0x696d2073","callData":"0x696d20736861726969696969696e67"}]}
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
Network | URL |
---|---|
Mainnet | https://mev-share.flashbots.net |
Goerli | https://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,
}>
}
Param | Type Info | Description |
---|---|---|
hash | Hex-string | Transaction hash. |
logs | Array of JSON-encoded events | Event logs emitted by executing the transaction. |
txs | Array of JSON objects | Transactions from the event. Will only be one if event is a transaction, otherwise event is a bundle. |
txs.callData | Hex-string | Calldata of the transaction. |
txs.functionSelector | Hex-string | 4-byte function selector. |
txs.to | Hex-string | Transaction 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.