Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions flashbotsrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"math/big"
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -617,8 +619,30 @@ func (rpc *FlashbotsRPC) FlashbotsGetUserStats(privKey *ecdsa.PrivateKey, blockN
return res, err
}

// FlashbotsCallBundle simulate a bundle against a specific block number
// https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint#eth_callbundle
func (rpc *FlashbotsRPC) FlashbotsCallBundle(privKey *ecdsa.PrivateKey, param FlashbotsCallBundleParam) (res FlashbotsCallBundleResponse, err error) {
// validate the input
if len(param.Txs) == 0 {
return FlashbotsCallBundleResponse{}, fmt.Errorf("txs are empty")
}

if param.BlockNumber == "" {
return FlashbotsCallBundleResponse{}, fmt.Errorf("blockNumber is empty")
}

blockNumber, err := strconv.ParseInt(strings.ReplaceAll(param.BlockNumber, "0x", ""), 16, 64)
if err != nil {
return FlashbotsCallBundleResponse{}, fmt.Errorf("blockNumber is invalid")
}
if blockNumber <= 0 {
return FlashbotsCallBundleResponse{}, fmt.Errorf("blockNumber is smaller than zero")
}

if param.StateBlockNumber == "" {
return FlashbotsCallBundleResponse{}, fmt.Errorf("stateBlockNumber is empty")
}

rawMsg, err := rpc.CallWithFlashbotsSignature("eth_callBundle", privKey, param)
if err != nil {
return res, err
Expand Down