Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/flashbots-auction/libraries/rust-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Rust Provider
---

Ethers-flashbots is a robust and user-friendly Rust library for interacting with flashbots.

By using this library, you can easily access the flashbots endpoints and send bundles of transactions with little effort from you favorite language.

This library is built on [ethers-rs,](https://github.com/gakonst/ethers-rs) which is a port of the popular ethers.js library, and it provides a convenient middleware layer for integrating with ethers-rs.

With ethers-flashbots, you can quickly and easily automate your trading activities on DEXs, allowing you to take advantage of market opportunities and maximize your profits. To learn more about ethers-flashbots and its features, visit the library's repository [here.](https://github.com/onbjerg/ethers-flashbots)
67 changes: 66 additions & 1 deletion docs/flashbots-auction/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Next, you need a means to communicate with the Flashbots network. The Flashbots
{ label: 'ethers.js', value: 'ethers.js', },
{ label: 'web3.py', value: 'web3.py' },
{ label: 'go', value: 'go' },
{ label: 'rust', value: 'rust'},
]}
>
<TabItem value="ethers.js">
Expand Down Expand Up @@ -169,10 +170,52 @@ func main() {
}
```

</TabItem>
<TabItem value="rust">

```rust
use ethers::core::rand::thread_rng;
use ethers::prelude::*;
use ethers_flashbots::*;
use std::convert::TryFrom;
use url::Url;

#[tokio::main]
async fn main() {
// Connect to the network
let provider = Provider::<Http>::try_from("https://www.ankr.com/rpc/eth/").unwrap();

// This is your searcher identity
let bundle_signer = LocalWallet::new(&mut thread_rng());

// This signs transactions and is randomly generated in this example
let wallet = LocalWallet::new(&mut thread_rng());

// Add signer and Flashbots middleware
let flashbots_client = SignerMiddleware::new(
FlashbotsMiddleware::new(
provider,
Url::parse("https://relay.flashbots.net").unwrap(),
bundle_signer,
),
wallet,
);
}
```

</TabItem>
</Tabs>

Now that we have a private key to identify ourselves with and a Flashbots provider we can create and send a bundle. Here's an example in node.js
Now that we have a private key to identify ourselves with and a Flashbots provider we can create and send a bundle. Here's how:

<Tabs
defaultValue="ethers.js"
values={[
{ label: 'ethers.js', value: 'ethers.js', },
{ label: 'rust', value: 'rust', },
]}
>
<TabItem value="ethers.js">

```js
const ethers = require("ethers.js");
Expand Down Expand Up @@ -204,6 +247,28 @@ const bundleReceipt = await flashbotsProvider.sendRawBundle(
);
```

</TabItem>
<TabItem value="rust">

See https://github.com/onbjerg/ethers-flashbots

```rust
let tx = TransactionRequest::pay("vitalik.eth", 100);
let pending_tx = client.send_transaction(tx, None).await?;

// Get the receipt
let receipt = pending_tx
.await?
.ok_or_else(|| eyre::format_err!("tx not included"))?;
let tx = client.get_transaction(receipt.transaction_hash).await?;

println!("Sent transaction: {}\n", serde_json::to_string(&tx)?);
println!("Receipt: {}\n", serde_json::to_string(&receipt)?);
```

</TabItem>
</Tabs>

That's it!

### Next steps
Expand Down
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'flashbots-auction/libraries/ethers-js-provider',
'flashbots-auction/libraries/web3py-provider',
'flashbots-auction/libraries/alchemyprovider',
'flashbots-auction/libraries/rust-provider',
],
"Advanced Concepts": [
'flashbots-auction/advanced/understanding-bundles',
Expand Down