reth_rpc_api/
reth.rs

1use alloy_eips::BlockId;
2use alloy_primitives::{Address, U256};
3use jsonrpsee::{core::RpcResult, proc_macros::rpc};
4use std::collections::HashMap;
5
6// Required for the subscription attribute below
7use reth_chain_state as _;
8
9/// Reth API namespace for reth-specific methods
10#[cfg_attr(not(feature = "client"), rpc(server, namespace = "reth"))]
11#[cfg_attr(feature = "client", rpc(server, client, namespace = "reth"))]
12pub trait RethApi {
13    /// Returns all ETH balance changes in a block
14    #[method(name = "getBalanceChangesInBlock")]
15    async fn reth_get_balance_changes_in_block(
16        &self,
17        block_id: BlockId,
18    ) -> RpcResult<HashMap<Address, U256>>;
19
20    /// Subscribe to json `ChainNotifications`
21    #[subscription(
22        name = "subscribeChainNotifications",
23        unsubscribe = "unsubscribeChainNotifications",
24        item = reth_chain_state::CanonStateNotification
25    )]
26    async fn reth_subscribe_chain_notifications(&self) -> jsonrpsee::core::SubscriptionResult;
27}