/flashbotsrpc

Golang client for Flashbots Relay (and standard Ethereum) JSON-RPC API calls

Primary LanguageGoMIT LicenseMIT

Flashbots RPC client

Fork of ethrpc with additional Flashbots RPC methods:

  • FlashbotsCallBundle (eth_callBundle)
  • FlashbotsSendBundle (eth_sendBundle)
  • FlashbotsGetUserStats (flashbots_getUserStats)
  • FlashbotsSendPrivateTransaction (eth_sendPrivateTransaction)
  • FlashbotsCancelPrivateTransaction (eth_cancelPrivateTransaction)
  • FlashbotsSimulateBlock: simulate a full block

Usage

go get github.com/metachris/flashbotsrpc

rpc := flashbotsrpc.New("https://relay.flashbots.net")

// Creating a new private key here for testing, you probably want to use an existing one
privateKey, _ := crypto.GenerateKey()

// flashbots_getUserStats example
// ------------------------------
result, err := rpc.FlashbotsGetUserStats(privateKey, 13281018)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%+v\n", result)

// eth_sendBundle example
// ----------------------
sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest{
    Txs:         []string{"YOUR_HASH"},
    BlockNumber: fmt.Sprintf("0x%x", 13281018),
}

result, err := rpc.FlashbotsSendBundle(privateKey, sendBundleArgs)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%+v\n", result)

You can find example code in the /examples/ directory.