referrerpolicy=no-referrer-when-downgrade

pallet_revive_eth_rpc/apis/
execution_apis.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Generated JSON-RPC methods.
19#![allow(missing_docs)]
20
21use crate::*;
22use jsonrpsee::{core::RpcResult, proc_macros::rpc};
23
24#[rpc(server, client)]
25pub trait EthRpc {
26	/// Returns a list of addresses owned by client.
27	#[method(name = "eth_accounts")]
28	async fn accounts(&self) -> RpcResult<Vec<Address>>;
29
30	/// Returns the number of most recent block.
31	#[method(name = "eth_blockNumber")]
32	async fn block_number(&self) -> RpcResult<U256>;
33
34	/// Executes a new message call immediately without creating a transaction on the block chain.
35	#[method(name = "eth_call")]
36	async fn call(
37		&self,
38		transaction: GenericTransaction,
39		block: Option<BlockNumberOrTagOrHash>,
40		state_overrides: Option<StateOverrideSet>,
41	) -> RpcResult<Bytes>;
42
43	/// Returns the chain ID of the current network.
44	#[method(name = "eth_chainId")]
45	async fn chain_id(&self) -> RpcResult<U256>;
46
47	/// Generates and returns an estimate of how much gas is necessary to allow the transaction to
48	/// complete.
49	#[method(name = "eth_estimateGas")]
50	async fn estimate_gas(
51		&self,
52		transaction: GenericTransaction,
53		block: Option<BlockNumberOrTag>,
54	) -> RpcResult<U256>;
55
56	/// Returns the current price per gas in wei.
57	#[method(name = "eth_gasPrice")]
58	async fn gas_price(&self) -> RpcResult<U256>;
59
60	/// Returns the balance of the account of given address.
61	#[method(name = "eth_getBalance")]
62	async fn get_balance(&self, address: Address, block: BlockNumberOrTagOrHash)
63	-> RpcResult<U256>;
64
65	/// Returns information about a block by hash.
66	#[method(name = "eth_getBlockByHash")]
67	async fn get_block_by_hash(
68		&self,
69		block_hash: H256,
70		hydrated_transactions: bool,
71	) -> RpcResult<Option<Block>>;
72
73	/// Returns information about a block by number.
74	#[method(name = "eth_getBlockByNumber")]
75	async fn get_block_by_number(
76		&self,
77		block: BlockNumberOrTag,
78		hydrated_transactions: bool,
79	) -> RpcResult<Option<Block>>;
80
81	/// Returns the number of transactions in a block from a block matching the given block hash.
82	#[method(name = "eth_getBlockTransactionCountByHash")]
83	async fn get_block_transaction_count_by_hash(
84		&self,
85		block_hash: Option<H256>,
86	) -> RpcResult<Option<U256>>;
87
88	/// Returns the number of transactions in a block matching the given block number.
89	#[method(name = "eth_getBlockTransactionCountByNumber")]
90	async fn get_block_transaction_count_by_number(
91		&self,
92		block: Option<BlockNumberOrTag>,
93	) -> RpcResult<Option<U256>>;
94
95	/// Returns code at a given address.
96	#[method(name = "eth_getCode")]
97	async fn get_code(&self, address: Address, block: BlockNumberOrTagOrHash) -> RpcResult<Bytes>;
98
99	/// Returns an array of all logs matching filter with given id.
100	#[method(name = "eth_getLogs")]
101	async fn get_logs(&self, filter: Option<Filter>) -> RpcResult<FilterResults>;
102
103	/// Returns the value from a storage position at a given address.
104	#[method(name = "eth_getStorageAt")]
105	async fn get_storage_at(
106		&self,
107		address: Address,
108		storage_slot: U256,
109		block: BlockNumberOrTagOrHash,
110	) -> RpcResult<Bytes>;
111
112	/// Returns information about a transaction by block hash and transaction index position.
113	#[method(name = "eth_getTransactionByBlockHashAndIndex")]
114	async fn get_transaction_by_block_hash_and_index(
115		&self,
116		block_hash: H256,
117		transaction_index: U256,
118	) -> RpcResult<Option<TransactionInfo>>;
119
120	/// Returns information about a transaction by block number and transaction index position.
121	#[method(name = "eth_getTransactionByBlockNumberAndIndex")]
122	async fn get_transaction_by_block_number_and_index(
123		&self,
124		block: BlockNumberOrTag,
125		transaction_index: U256,
126	) -> RpcResult<Option<TransactionInfo>>;
127
128	/// Returns the information about a transaction requested by transaction hash.
129	#[method(name = "eth_getTransactionByHash")]
130	async fn get_transaction_by_hash(
131		&self,
132		transaction_hash: H256,
133	) -> RpcResult<Option<TransactionInfo>>;
134
135	/// Returns the number of transactions sent from an address.
136	#[method(name = "eth_getTransactionCount")]
137	async fn get_transaction_count(
138		&self,
139		address: Address,
140		block: BlockNumberOrTagOrHash,
141	) -> RpcResult<U256>;
142
143	/// Returns the receipt of a transaction by transaction hash.
144	#[method(name = "eth_getTransactionReceipt")]
145	async fn get_transaction_receipt(
146		&self,
147		transaction_hash: H256,
148	) -> RpcResult<Option<ReceiptInfo>>;
149
150	/// Returns the current maxPriorityFeePerGas per gas in wei.
151	#[method(name = "eth_maxPriorityFeePerGas")]
152	async fn max_priority_fee_per_gas(&self) -> RpcResult<U256>;
153
154	/// Submits a raw transaction. For EIP-4844 transactions, the raw form must be the network form.
155	/// This means it includes the blobs, KZG commitments, and KZG proofs.
156	#[method(name = "eth_sendRawTransaction")]
157	async fn send_raw_transaction(&self, transaction: Bytes) -> RpcResult<H256>;
158
159	/// Signs and submits a transaction.
160	#[method(name = "eth_sendTransaction")]
161	async fn send_transaction(&self, transaction: GenericTransaction) -> RpcResult<H256>;
162
163	/// Returns an object with data about the sync status or false.
164	#[method(name = "eth_syncing")]
165	async fn syncing(&self) -> RpcResult<SyncingStatus>;
166
167	/// Returns true when the client is actively listening for network connections, otherwise false
168	#[method(name = "net_listening")]
169	async fn net_listening(&self) -> RpcResult<bool>;
170
171	/// The string value of current network id
172	#[method(name = "net_version")]
173	async fn net_version(&self) -> RpcResult<String>;
174
175	/// The string value of the current client version
176	#[method(name = "web3_clientVersion")]
177	async fn web3_client_version(&self) -> RpcResult<String>;
178
179	/// Returns transaction base fee per gas and effective priority fee per gas for the
180	/// requested/supported block range.
181	///
182	/// Transaction fee history, which is introduced in EIP-1159.
183	#[method(name = "eth_feeHistory")]
184	async fn fee_history(
185		&self,
186		block_count: U256,
187		newest_block: BlockNumberOrTag,
188		reward_percentiles: Option<Vec<f64>>,
189	) -> RpcResult<FeeHistoryResult>;
190
191	/// Creates a subscription to specific events, returning a subscription ID.
192	/// Notifications are sent for each event matching the subscription via
193	/// `eth_subscription`.
194	#[subscription(
195		name = "eth_subscribe" => "eth_subscription",
196		unsubscribe = "eth_unsubscribe",
197		item = SubscriptionItem
198	)]
199	async fn eth_subscribe(&self, kind: SubscriptionKind, options: Option<SubscriptionOptions>);
200}