Categorygithub.com/lmittmann/flashbots
modulepackage
0.7.1
Repository: https://github.com/lmittmann/flashbots.git
Documentation: pkg.go.dev

# README

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)

# Functions

AuthTransport returns a http.RoundTripper that adds the 'X-Flashbots-Signature' header to every request.
BundleStats requests the bundles Flashbots relay stats.
BundleStatsV2 requests the bundles Flashbots relay stats.
CallBundle simulates a bundle.
CancelPrivateTx stops the private transactions with the given hash from being submitted for future blocks by the Flashbots relay.
Dial returns a new [w3.Client] connected to the URL rawurl that adds the 'X-Flashbots-Signature' to every request.
MustDial is like [Dial] but panics if the connection establishment fails.
SendBundle sends the bundle to the client's endpoint.
SendPrivateTx sends a private transaction to the Flashbots relay.
UserStats requests the users Flashbots relay stats.
UserStatsV2 requests the users Flashbots relay stats.

# Structs

Deprecated: Use [BundleStatsV2Response] instead.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Deprecated: Use [UserStatsV2Response] instead.
No description provided by the author