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