|
2 | 2 |
|
3 | 3 | Fork of [ethrpc](https://github.com/onrik/ethrpc) with additional [Flashbots RPC methods](https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint):
|
4 | 4 |
|
5 |
| -* `FlashbotsGetUserStats` |
6 |
| -* `FlashbotsCallBundle` |
7 |
| -* `FlashbotsSendBundle` |
| 5 | +* `FlashbotsCallBundle` ([`eth_callBundle`](https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint/#eth_callbundle)) |
| 6 | +* `FlashbotsSendBundle` ([`eth_sendBundle`](https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint/#eth_sendbundle)) |
| 7 | +* `FlashbotsGetUserStats` ([`flashbots_getUserStats`](https://docs.flashbots.net/flashbots-auction/searchers/advanced/rpc-endpoint/#flashbots_getuserstats)) |
8 | 8 | * `FlashbotsSimulateBlock`: simulate a full block
|
9 | 9 |
|
10 | 10 | ## Usage
|
11 | 11 |
|
| 12 | +`go get github.com/metachris/flashbotsrpc` |
| 13 | + |
12 | 14 | ```go
|
13 | 15 | rpc := flashbotsrpc.New("https://relay.flashbots.net")
|
14 | 16 |
|
15 | 17 | // Creating a new private key here for testing, you probably want to use an existing one
|
16 | 18 | privateKey, _ := crypto.GenerateKey()
|
17 | 19 |
|
18 |
| -func getUserStats() { |
19 |
| - result, err := rpc.FlashbotsGetUserStats(privateKey, 13281018) |
20 |
| - if err != nil { |
21 |
| - log.Fatal(err) |
22 |
| - } |
23 |
| - |
24 |
| - // Print result |
25 |
| - fmt.Printf("%+v\n", result) |
| 20 | +// flashbots_getUserStats example |
| 21 | +// ------------------------------ |
| 22 | +result, err := rpc.FlashbotsGetUserStats(privateKey, 13281018) |
| 23 | +if err != nil { |
| 24 | + log.Fatal(err) |
26 | 25 | }
|
| 26 | +fmt.Printf("%+v\n", result) |
27 | 27 |
|
28 |
| -func sendBundle() { |
29 |
| - sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest{ |
30 |
| - Txs: []string{"YOUR_HASH"}, |
31 |
| - BlockNumber: fmt.Sprintf("0x%x", 13281018), |
32 |
| - } |
33 |
| - |
34 |
| - result, err := rpc.FlashbotsSendBundle(privateKey, sendBundleArgs) |
35 |
| - if err != nil { |
36 |
| - log.Fatal(err) |
37 |
| - } |
| 28 | +// eth_sendBundle example |
| 29 | +// ---------------------- |
| 30 | +sendBundleArgs := flashbotsrpc.FlashbotsSendBundleRequest{ |
| 31 | + Txs: []string{"YOUR_HASH"}, |
| 32 | + BlockNumber: fmt.Sprintf("0x%x", 13281018), |
| 33 | +} |
38 | 34 |
|
39 |
| - // Print result |
40 |
| - fmt.Printf("%+v\n", result) |
| 35 | +result, err := rpc.FlashbotsSendBundle(privateKey, sendBundleArgs) |
| 36 | +if err != nil { |
| 37 | + log.Fatal(err) |
41 | 38 | }
|
| 39 | +fmt.Printf("%+v\n", result) |
42 | 40 | ```
|
43 | 41 |
|
44 |
| -You can find [more examples in `/examples/`](https://github.com/metachris/flashbotsrpc/tree/master/examples). |
| 42 | +You can find example code in the [`/examples/` directory](https://github.com/metachris/flashbotsrpc/tree/master/examples). |
0 commit comments