@@ -11,26 +11,48 @@ Fork of [ethrpc](https://github.com/onrik/ethrpc) with additional [Flashbots RPC
11
11
12
12
## Usage
13
13
14
+ Add library to your project:
15
+
14
16
` go get github.com/metachris/flashbotsrpc `
15
17
16
- ``` go
17
- rpc := flashbotsrpc.New (" https://relay.flashbots.net" )
18
+ Create a new private key here for testing (you probably want to use an existing one):
18
19
19
- // Creating a new private key here for testing, you probably want to use an existing one
20
+ ``` go
20
21
privateKey , _ := crypto.GenerateKey ()
22
+ ```
23
+
24
+ #### Simulate transactions with ` eth_callBundle ` :
25
+
26
+ ``` go
27
+ callBundleArgs := flashbotsrpc.FlashbotsCallBundleParam {
28
+ Txs : []string {" YOUR_RAW_TX" },
29
+ BlockNumber : fmt.Sprintf (" 0x%x " , 13281018 ),
30
+ StateBlockNumber : " latest" ,
31
+ }
32
+
33
+ result , err := rpc.FlashbotsCallBundle (privateKey, callBundleArgs)
34
+ if err != nil {
35
+ log.Fatal (err)
36
+ }
37
+ fmt.Printf (" %+v \n " , result)
38
+ ```
39
+
40
+ #### Get Flashbots user stats:
21
41
22
- // flashbots_getUserStats example
23
- // ------------------------------
42
+ ``` go
43
+ rpc := flashbotsrpc. New ( " https://relay.flashbots.net " )
24
44
result , err := rpc.FlashbotsGetUserStats (privateKey, 13281018 )
25
45
if err != nil {
26
46
log.Fatal (err)
27
47
}
28
48
fmt.Printf (" %+v \n " , result)
49
+ ```
50
+
51
+ #### Send a transaction bundle to Flashbots with ` eth_sendBundle ` :
29
52
30
- // eth_sendBundle example
31
- // ----------------------
53
+ ``` go
32
54
sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest {
33
- Txs : []string {" YOUR_HASH " },
55
+ Txs : []string {" YOUR_RAW_TX " },
34
56
BlockNumber : fmt.Sprintf (" 0x%x " , 13281018 ),
35
57
}
36
58
@@ -41,4 +63,6 @@ if err != nil {
41
63
fmt.Printf (" %+v \n " , result)
42
64
```
43
65
66
+ #### More examples
67
+
44
68
You can find example code in the [ ` /examples/ ` directory] ( https://github.com/metachris/flashbotsrpc/tree/master/examples ) .
0 commit comments