Skip to content

【go实现的MEV套利机器人示例】Package flashbots implements RPC API bindings for the Flashbots relay and mev-geth for use with the w3 package.

License

Notifications You must be signed in to change notification settings

GavinMakeMoney/flashbots

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Connect to the Flashbots relay. The AuthTransport adds the X-Flashbots-Signature header to every request from the client.

// Private key for request authentication
var privKey *ecdsa.PrivateKey

// Connect to Flashbots relay
rpcClient, err := rpc.DialHTTPWithClient(
	"https://relay.flashbots.net",
	&http.Client{
		Transport: flashbots.AuthTransport(privKey),
	},
)

// Create w3 client form rpc client
client := w3.NewClient(rpcClient)
defer client.Close()

Send a bundle to the Flashbots relay.

var bundle types.Transactions // list of signed transactions

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

⚠ 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.SendPrivateTransaction(r *flashbots.SendPrivateTransactionRequest).Returns(txHash *common.Hash)
eth_cancelPrivateTransaction flashbots.CancelPrivateTransaction(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)

About

【go实现的MEV套利机器人示例】Package flashbots implements RPC API bindings for the Flashbots relay and mev-geth for use with the w3 package.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%