Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 3.14 KB

README.md

File metadata and controls

74 lines (54 loc) · 3.14 KB

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.

Method Go Code
eth_sendBundle flashbots.SendBundle(r *flashbots.SendBundleRequest).Returns(bundleHash *common.Hash)
eth_callBundle flashbots.CallBundle(r *flashbots.CallBundleRequest).Returns(resp **flashbots.CallBundleResponse)
eth_sendPrivateTransaction flashbots.SendPrivateTx(r *flashbots.SendPrivateTxRequest).Returns(txHash *common.Hash)
eth_cancelPrivateTransaction flashbots.CancelPrivateTx(txHash common.Hash).Returns(success *bool)
flashbots_getUserStats flashbots.UserStats(blockNumber *big.Int).Returns(resp **flashbots.UserStatsResponse)
flashbots_getBundleStats flashbots.BundleStats(bundleHash common.Hash, blockNumber *big.Int).Returns(resp **flashbots.BundleStatsResponse)
flashbots_getUserStatsV2 flashbots.UserStatsV2(blockNumber *big.Int).Returns(resp **flashbots.UserStatsV2Response)
flashbots_getBundleStatsV2 flashbots.BundleStatsV2(bundleHash common.Hash, blockNumber *big.Int).Returns(resp **flashbots.BundleStatsV2Response)