1use alloy::{
2 primitives::{Address, Bytes, B256, U256},
3 rpc::types::{Block, BlockId, BlockNumberOrTag, TransactionRequest},
4};
5use jsonrpsee::{core::RpcResult, proc_macros::rpc};
6
7#[rpc(client, server, namespace = "eth")]
9pub trait EthApi {
10 #[method(name = "chainId")]
11 async fn chain_id(&self) -> RpcResult<U256>;
12
13 #[method(name = "getBlockByNumber")]
14 async fn get_block_by_number(
15 &self,
16 block_number_or_tag: BlockNumberOrTag,
17 hydrated_transactions: bool,
18 ) -> RpcResult<Block>;
19
20 #[method(name = "getBlockByHash")]
21 async fn get_block_by_hash(
22 &self,
23 block_hash: B256,
24 hydrated_transactions: bool,
25 ) -> RpcResult<Block>;
26
27 #[method(name = "getBalance")]
28 async fn get_balance(&self, address: Address, block: BlockId) -> RpcResult<U256>;
29
30 #[method(name = "getCode")]
31 async fn get_code(&self, address: Address, block: BlockId) -> RpcResult<Bytes>;
32
33 #[method(name = "getStorageAt")]
34 async fn get_storage_at(&self, address: Address, slot: U256, block: BlockId)
35 -> RpcResult<B256>;
36
37 #[method(name = "call")]
38 async fn call(&self, transaction: TransactionRequest, block: BlockId) -> RpcResult<Bytes>;
39}