-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* broadcaster impl * update README to include example for broadcast bundle
- Loading branch information
1 parent
f234223
commit 702086e
Showing
4 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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() { | ||
urls := []string{ | ||
"https://relay.flashbots.net", | ||
"https://rpc.titanbuilder.xyz", | ||
"https://builder0x69.io", | ||
"https://rpc.beaverbuild.org", | ||
"https://rsync-builder.xyz", | ||
"https://api.blocknative.com/v1/auction", | ||
// "https://mev.api.blxrbdn.com", # Authentication required | ||
"https://eth-builder.com", | ||
"https://builder.gmbit.co/rpc", | ||
"https://buildai.net", | ||
"https://rpc.payload.de", | ||
"https://rpc.lightspeedbuilder.info", | ||
"https://rpc.nfactorial.xyz", | ||
} | ||
|
||
rpc := flashbotsrpc.NewBuilderBroadcastRPC(urls) | ||
rpc.Debug = true | ||
|
||
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 { | ||
if errors.Is(result.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(result.Err.Error()) | ||
} else { | ||
fmt.Printf("error: %+v\n", result.Err) | ||
} | ||
return | ||
} | ||
|
||
// Print result | ||
fmt.Printf("%+v\n", result.BundleResponse) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters