Home

Awesome

flashbots ⚡🤖

Go Reference Go Report Card Coverage Status Latest Release

Package flashbots implements RPC API bindings for the Flashbots relay and mev-geth for use with the w3 package.

Install

go get github.com/lmittmann/flashbots

Getting Started

[!NOTE] Check out the examples!

Connect to the Flashbots relay. The w3.Client returned by Dial uses the AuthTransport to add the X-Flashbots-Signature header to every request.

// Private key for request signing.
var prv *ecdsa.PrivateKey

// Connect to Flashbots Relay
client := flashbots.MustDial("https://relay.flashbots.net", prv)
defer client.Close()

// Or… Connect to any RPC endpoint that does not require signed requests
client := w3.MustDial("http://localhost:8545")
defer client.Close()

Send a bundle to the Flashbots relay.

bundle := []*types.Transaction{ /* signed transactions… */ }

var bundleHash common.Hash
err := client.Call(
	flashbots.SendBundle(&flashbots.SendBundleRequest{
		Transactions: bundle,
		BlockNumber:  big.NewInt(999_999_999),
	}).Returns(&bundleHash),
)

[!WARNING] The Flashbots relay does not support batch requests. Thus, sending more than one call in Client.Call will result in a server error.

RPC Methods

List of supported RPC methods.

MethodGo Code
eth_sendBundleflashbots.SendBundle(r *flashbots.SendBundleRequest).Returns(bundleHash *common.Hash)
eth_callBundleflashbots.CallBundle(r *flashbots.CallBundleRequest).Returns(resp **flashbots.CallBundleResponse)
eth_sendPrivateTransactionflashbots.SendPrivateTx(r *flashbots.SendPrivateTxRequest).Returns(txHash *common.Hash)
eth_cancelPrivateTransactionflashbots.CancelPrivateTx(txHash common.Hash).Returns(success *bool)
flashbots_getUserStatsflashbots.UserStats(blockNumber *big.Int).Returns(resp **flashbots.UserStatsResponse)
flashbots_getBundleStatsflashbots.BundleStats(bundleHash common.Hash, blockNumber *big.Int).Returns(resp **flashbots.BundleStatsResponse)
flashbots_getUserStatsV2flashbots.UserStatsV2(blockNumber *big.Int).Returns(resp **flashbots.UserStatsV2Response)
flashbots_getBundleStatsV2flashbots.BundleStatsV2(bundleHash common.Hash, blockNumber *big.Int).Returns(resp **flashbots.BundleStatsV2Response)