forked from ifhbr0/flashbotsrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (29 loc) · 974 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"errors"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"github.com/metachris/flashbotsrpc"
)
var privateKey, _ = crypto.GenerateKey() // creating a new private key for testing. you probably want to use an existing key.
// var privateKey, _ = crypto.HexToECDSA("YOUR_PRIVATE_KEY")
func main() {
rpc := flashbotsrpc.New("https://relay.flashbots.net")
rpc.Debug = true
sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest{
Txs: []string{"YOUR_RAW_TX"},
BlockNumber: fmt.Sprintf("0x%x", 13281018),
}
result, err := rpc.FlashbotsSendBundle(privateKey, sendBundleArgs)
if err != nil {
if errors.Is(err, flashbotsrpc.ErrRelayErrorResponse) {
// ErrRelayErrorResponse means it's a standard Flashbots relay error response, so probably a user error, rather than JSON or network error
fmt.Println(err.Error())
} else {
fmt.Printf("error: %+v\n", err)
}
return
}
// Print result
fmt.Printf("%+v\n", result)
}