modulepackage
0.5.5
Repository: https://github.com/anomalyfi/flashbotsrpc.git
Documentation: pkg.go.dev
# README
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
Add library to your project:
go get github.com/AnomalyFi/flashbotsrpc
Create a new private key here for testing (you probably want to use an existing one):
privateKey, _ := crypto.GenerateKey()
Simulate transactions with eth_callBundle
:
callBundleArgs := flashbotsrpc.FlashbotsCallBundleParam{
Txs: []string{"YOUR_RAW_TX"},
BlockNumber: fmt.Sprintf("0x%x", 13281018),
StateBlockNumber: "latest",
}
result, err := rpc.FlashbotsCallBundle(privateKey, callBundleArgs)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", result)
Get Flashbots user stats:
rpc := flashbotsrpc.New("https://relay.flashbots.net")
result, err := rpc.FlashbotsGetUserStats(privateKey, 13281018)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", result)
Send a transaction bundle to Flashbots with eth_sendBundle
:
sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest{
Txs: []string{"YOUR_RAW_TX"},
BlockNumber: fmt.Sprintf("0x%x", 13281018),
}
result, err := rpc.FlashbotsSendBundle(privateKey, sendBundleArgs)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", result)
Send a transaction bundle to a list of Builder endpoints with eth_sendBundle
(full example [/examples/broadcastbundle]):
urls := []string{
"https://relay.flashbots.net",
// Refer to https://www.mev.to/builders for builder endpoints
}
rpc := flashbotsrpc.NewBuilderBroadcastRPC(urls)
sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest{
Txs: []string{"YOUR_RAW_TX"},
BlockNumber: fmt.Sprintf("0x%x", 13281018),
}
results := rpc.BroadcastBundle(privateKey, sendBundleArgs)
for _, result := range results {
if result.Err != nil {
log.Fatal(result.Err)
}
fmt.Printf("%+v\n", result.BundleResponse)
}
More examples
You can find example code in the /examples/
directory.
# Packages
No description provided by the author
# Functions
BigToHex covert big.Int to hexadecimal representation.
Eth1 returns 1 ethereum value (10^18 wei).
IntToHex convert int to hexadecimal representation.
New create new rpc client with given url.
NewBuilderBroadcastRPC create broadcaster rpc client with given url.
NewFlashbotsRPC create new rpc client with given url.
ParseBigInt parse hex string value to big.Int.
ParseInt parse hex string value to int.
No description provided by the author
WithDebug set debug flag.
WithHttpClient set custom http client.
WithLogger set custom logger.
# Variables
ErrRelayErrorResponse means it's a standard Flashbots relay error response - probably a user error rather than JSON or network error.
# Structs
Block - block object.
No description provided by the author
No description provided by the author
No description provided by the author
FilterParams - Filter parameters object.
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
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
cancelPrivateTransaction.
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
FlashbotsRPC - Ethereum rpc client.
No description provided by the author
No description provided by the author
sendBundle.
No description provided by the author
sendPrivateTransaction.
No description provided by the author
Log - log object.
No description provided by the author
RpcError - ethereum error.
Syncing - object with syncing data info.
T - input transaction object.
Transaction - transaction object.
TransactionReceipt - transaction receipt object.
# Interfaces
No description provided by the author