reth_rpc_eth_api/bundle.rs
1//! Additional `eth_` RPC API for bundles.
2//!
3//! See also <https://docs.flashbots.net/flashbots-auction/advanced/rpc-endpoint>
4
5use alloy_primitives::{Bytes, B256};
6use alloy_rpc_types_mev::{
7 EthBundleHash, EthCallBundle, EthCallBundleResponse, EthCancelBundle,
8 EthCancelPrivateTransaction, EthSendBundle, EthSendPrivateTransaction,
9};
10use jsonrpsee::proc_macros::rpc;
11
12/// A subset of the [`EthBundleApi`] API interface that only supports `eth_callBundle`.
13#[rpc(server, namespace = "eth")]
14pub trait EthCallBundleApi {
15 /// `eth_callBundle` can be used to simulate a bundle against a specific block number,
16 /// including simulating a bundle at the top of the next block.
17 #[method(name = "callBundle")]
18 async fn call_bundle(
19 &self,
20 request: EthCallBundle,
21 ) -> jsonrpsee::core::RpcResult<EthCallBundleResponse>;
22}
23
24/// The __full__ Eth bundle rpc interface.
25///
26/// See also <https://docs.flashbots.net/flashbots-auction/advanced/rpc-endpoint>
27#[rpc(server, namespace = "eth")]
28pub trait EthBundleApi {
29 /// `eth_sendBundle` can be used to send your bundles to the builder.
30 #[method(name = "sendBundle")]
31 async fn send_bundle(&self, bundle: EthSendBundle)
32 -> jsonrpsee::core::RpcResult<EthBundleHash>;
33
34 /// `eth_callBundle` can be used to simulate a bundle against a specific block number,
35 /// including simulating a bundle at the top of the next block.
36 #[method(name = "callBundle")]
37 async fn call_bundle(
38 &self,
39 request: EthCallBundle,
40 ) -> jsonrpsee::core::RpcResult<EthCallBundleResponse>;
41
42 /// `eth_cancelBundle` is used to prevent a submitted bundle from being included on-chain. See [bundle cancellations](https://docs.flashbots.net/flashbots-auction/advanced/bundle-cancellations) for more information.
43 #[method(name = "cancelBundle")]
44 async fn cancel_bundle(&self, request: EthCancelBundle) -> jsonrpsee::core::RpcResult<()>;
45
46 /// `eth_sendPrivateTransaction` is used to send a single transaction to Flashbots. Flashbots will attempt to build a block including the transaction for the next 25 blocks. See [Private Transactions](https://docs.flashbots.net/flashbots-protect/additional-documentation/eth-sendPrivateTransaction) for more info.
47 #[method(name = "sendPrivateTransaction")]
48 async fn send_private_transaction(
49 &self,
50 request: EthSendPrivateTransaction,
51 ) -> jsonrpsee::core::RpcResult<B256>;
52
53 /// The `eth_sendPrivateRawTransaction` method can be used to send private transactions to
54 /// the RPC endpoint. Private transactions are protected from frontrunning and kept
55 /// private until included in a block. A request to this endpoint needs to follow
56 /// the standard `eth_sendRawTransaction`
57 #[method(name = "sendPrivateRawTransaction")]
58 async fn send_private_raw_transaction(&self, bytes: Bytes) -> jsonrpsee::core::RpcResult<B256>;
59
60 /// The `eth_cancelPrivateTransaction` method stops private transactions from being
61 /// submitted for future blocks.
62 ///
63 /// A transaction can only be cancelled if the request is signed by the same key as the
64 /// `eth_sendPrivateTransaction` call submitting the transaction in first place.
65 #[method(name = "cancelPrivateTransaction")]
66 async fn cancel_private_transaction(
67 &self,
68 request: EthCancelPrivateTransaction,
69 ) -> jsonrpsee::core::RpcResult<bool>;
70}