ethrpc/
lib.rs

1//! A simple Ethereum RPC implementation.
2
3#[cfg(feature = "curl")]
4pub mod curl;
5#[cfg(feature = "http")]
6pub mod http;
7pub mod jsonrpc;
8#[macro_use]
9pub mod method;
10mod bloom;
11mod debug;
12mod serialization;
13pub mod types;
14
15use self::types::*;
16
17module! {
18    /// The `web3` namespace.
19    pub mod web3 {
20        /// Gets the current client version.
21        pub struct ClientVersion as "web3_clientVersion"
22            Empty => String;
23    }
24}
25
26module! {
27    /// The `eth` namespace.
28    ///
29    /// Documentation for the APIs can be found here:
30    /// <https://ethereum.github.io/execution-apis/api-documentation/>
31    pub mod eth {
32        /// Gets the current client version.
33        pub struct BlockNumber as "eth_blockNumber"
34            Empty => U256;
35
36        /// Simulates a transaction without adding it to the blockchain.
37        pub struct Call as "eth_call"
38            (TransactionCall, BlockId) => Vec<u8> [serialization::bytes];
39
40        /// Returns information about a block by hash.
41        pub struct GetBlockByHash as "eth_getBlockByHash"
42            (Digest, Hydrated) => Option<Block>;
43
44        /// Returns information about a block by number.
45        pub struct GetBlockByNumber as "eth_getBlockByNumber"
46            (BlockSpec, Hydrated) => Option<Block>;
47
48        /// Returns the number of transactions in a block from a block matching the given block hash.
49        pub struct GetBlockTransactionCountByHash as "eth_getBlockTransactionCountByHash"
50            (Digest,) => Option<U256>;
51
52        /// Returns the number of transactions in a block matching the given block number.
53        pub struct GetBlockTransactionCountByNumber as "eth_getBlockTransactionCountByNumber"
54            (BlockSpec,) => Option<U256>;
55
56        /// Returns code at a given address.
57        pub struct GetCode as "eth_getCode"
58            (Address, BlockId) => Vec<u8> [serialization::bytes];
59
60        /// Returns a collection of all logs matching the given filter.
61        pub struct GetLogs as "eth_getLogs"
62            (LogFilter,) => Vec<Log>;
63
64        /// Returns information about a transaction by block hash and transaction index position.
65        pub struct GetTransactionByBlockHashAndIndex as "eth_getTransactionByBlockHashAndIndex"
66            (Digest, U256) => Option<SignedTransaction>;
67
68        /// Returns information about a transaction by block number and transaction index position.
69        pub struct GetTransactionByBlockNumberAndIndex as "eth_getTransactionByBlockNumberAndIndex"
70            (BlockSpec, U256) => Option<SignedTransaction>;
71
72        /// Returns information about a transaction requested by transaction hash.
73        pub struct GetTransactionByHash as "eth_getTransactionByHash"
74            (Digest,) => Option<SignedTransaction>;
75    }
76}
77
78/// Module containing common extensions to the standard Ethereum RPC methods.
79pub mod ext {
80    use crate::{serialization, types::*};
81
82    module! {
83        /// Extensions to the `eth` namespace.
84        pub mod eth {
85            /// Simulates a transaction without adding it to the blockchain with
86            /// support for state overrides.
87            pub struct Call as "eth_call"
88                (TransactionCall, BlockId, StateOverrides) => Vec<u8> [serialization::bytes];
89        }
90    }
91}