pub struct EthApi {
pool: Arc<Pool>,
pub backend: Arc<Backend>,
is_mining: bool,
signers: Arc<Vec<Box<dyn Signer>>>,
fee_history_cache: FeeHistoryCache,
fee_history_limit: u64,
miner: Miner,
logger: LoggingManager,
filters: Filters,
transaction_order: Arc<RwLock<TransactionOrder>>,
net_listening: bool,
instance_id: Arc<RwLock<B256>>,
}
Expand description
The entry point for executing eth api RPC call - The Eth RPC interface.
This type is cheap to clone and can be used concurrently
Fields§
§pool: Arc<Pool>
The transaction pool
backend: Arc<Backend>
Holds all blockchain related data In-Memory only for now
is_mining: bool
Whether this node is mining
signers: Arc<Vec<Box<dyn Signer>>>
available signers
fee_history_cache: FeeHistoryCache
data required for eth_feeHistory
fee_history_limit: u64
max number of items kept in fee cache
miner: Miner
access to the actual miner
This access is required in order to adjust miner settings based on requests received from custom RPC endpoints
logger: LoggingManager
allows to enabled/disable logging
filters: Filters
Tracks all active filters
transaction_order: Arc<RwLock<TransactionOrder>>
How transactions are ordered in the pool
net_listening: bool
Whether we’re listening for RPC calls
instance_id: Arc<RwLock<B256>>
The instance ID. Changes on every reset.
Implementations§
Source§impl EthApi
impl EthApi
Sourcepub fn new(
pool: Arc<Pool>,
backend: Arc<Backend>,
signers: Arc<Vec<Box<dyn Signer>>>,
fee_history_cache: FeeHistoryCache,
fee_history_limit: u64,
miner: Miner,
logger: LoggingManager,
filters: Filters,
transactions_order: TransactionOrder,
) -> Self
pub fn new( pool: Arc<Pool>, backend: Arc<Backend>, signers: Arc<Vec<Box<dyn Signer>>>, fee_history_cache: FeeHistoryCache, fee_history_limit: u64, miner: Miner, logger: LoggingManager, filters: Filters, transactions_order: TransactionOrder, ) -> Self
Creates a new instance
Sourcepub async fn execute(&self, request: EthRequest) -> ResponseResult
pub async fn execute(&self, request: EthRequest) -> ResponseResult
Executes the [EthRequest] and returns an RPC [ResponseResult].
fn sign_request( &self, from: &Address, request: TypedTransactionRequest, ) -> Result<TypedTransaction, BlockchainError>
async fn block_request( &self, block_number: Option<BlockId>, ) -> Result<BlockRequest, BlockchainError>
async fn inner_raw_transaction( &self, hash: B256, ) -> Result<Option<Bytes>, BlockchainError>
Sourcepub fn client_version(&self) -> Result<String, BlockchainError>
pub fn client_version(&self) -> Result<String, BlockchainError>
Returns the current client version.
Handler for ETH RPC call: web3_clientVersion
Sourcepub fn sha3(&self, bytes: Bytes) -> Result<String, BlockchainError>
pub fn sha3(&self, bytes: Bytes) -> Result<String, BlockchainError>
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
Handler for ETH RPC call: web3_sha3
Sourcepub fn protocol_version(&self) -> Result<u64, BlockchainError>
pub fn protocol_version(&self) -> Result<u64, BlockchainError>
Returns protocol version encoded as a string (quotes are necessary).
Handler for ETH RPC call: eth_protocolVersion
Sourcepub fn hashrate(&self) -> Result<U256, BlockchainError>
pub fn hashrate(&self) -> Result<U256, BlockchainError>
Returns the number of hashes per second that the node is mining with.
Handler for ETH RPC call: eth_hashrate
Returns the client coinbase address.
Handler for ETH RPC call: eth_coinbase
Sourcepub fn is_mining(&self) -> Result<bool, BlockchainError>
pub fn is_mining(&self) -> Result<bool, BlockchainError>
Returns true if client is actively mining new blocks.
Handler for ETH RPC call: eth_mining
Sourcepub fn eth_chain_id(&self) -> Result<Option<U64>, BlockchainError>
pub fn eth_chain_id(&self) -> Result<Option<U64>, BlockchainError>
Returns the chain ID used for transaction signing at the current best block. None is returned if not available.
Handler for ETH RPC call: eth_chainId
Sourcepub fn network_id(&self) -> Result<Option<String>, BlockchainError>
pub fn network_id(&self) -> Result<Option<String>, BlockchainError>
Returns the same as chain_id
Handler for ETH RPC call: eth_networkId
Sourcepub fn net_listening(&self) -> Result<bool, BlockchainError>
pub fn net_listening(&self) -> Result<bool, BlockchainError>
Returns true if client is actively listening for network connections.
Handler for ETH RPC call: net_listening
Sourcefn eth_gas_price(&self) -> Result<U256, BlockchainError>
fn eth_gas_price(&self) -> Result<U256, BlockchainError>
Returns the current gas price
Sourcepub fn excess_blob_gas_and_price(
&self,
) -> Result<Option<BlobExcessGasAndPrice>, BlockchainError>
pub fn excess_blob_gas_and_price( &self, ) -> Result<Option<BlobExcessGasAndPrice>, BlockchainError>
Returns the excess blob gas and current blob gas price
Sourcepub fn gas_max_priority_fee_per_gas(&self) -> Result<U256, BlockchainError>
pub fn gas_max_priority_fee_per_gas(&self) -> Result<U256, BlockchainError>
Returns a fee per gas that is an estimate of how much you can pay as a priority fee, or ‘tip’, to get a transaction included in the current block.
Handler for ETH RPC call: eth_maxPriorityFeePerGas
Sourcepub fn blob_base_fee(&self) -> Result<U256, BlockchainError>
pub fn blob_base_fee(&self) -> Result<U256, BlockchainError>
Returns the base fee per blob required to send a EIP-4844 tx.
Handler for ETH RPC call: eth_blobBaseFee
Sourcepub fn accounts(&self) -> Result<Vec<Address>, BlockchainError>
pub fn accounts(&self) -> Result<Vec<Address>, BlockchainError>
Returns the accounts list
Handler for ETH RPC call: eth_accounts
Sourcepub fn block_number(&self) -> Result<U256, BlockchainError>
pub fn block_number(&self) -> Result<U256, BlockchainError>
Returns the number of most recent block.
Handler for ETH RPC call: eth_blockNumber
Sourcepub async fn balance(
&self,
address: Address,
block_number: Option<BlockId>,
) -> Result<U256, BlockchainError>
pub async fn balance( &self, address: Address, block_number: Option<BlockId>, ) -> Result<U256, BlockchainError>
Returns balance of the given account.
Handler for ETH RPC call: eth_getBalance
Sourcepub async fn get_account(
&self,
address: Address,
block_number: Option<BlockId>,
) -> Result<Account, BlockchainError>
pub async fn get_account( &self, address: Address, block_number: Option<BlockId>, ) -> Result<Account, BlockchainError>
Returns the ethereum account.
Handler for ETH RPC call: eth_getAccount
Sourcepub async fn storage_at(
&self,
address: Address,
index: U256,
block_number: Option<BlockId>,
) -> Result<B256, BlockchainError>
pub async fn storage_at( &self, address: Address, index: U256, block_number: Option<BlockId>, ) -> Result<B256, BlockchainError>
Returns content of the storage at given address.
Handler for ETH RPC call: eth_getStorageAt
Sourcepub async fn block_by_hash(
&self,
hash: B256,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn block_by_hash( &self, hash: B256, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Returns block with given hash.
Handler for ETH RPC call: eth_getBlockByHash
Sourcepub async fn block_by_hash_full(
&self,
hash: B256,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn block_by_hash_full( &self, hash: B256, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Returns a full block with given hash.
Handler for ETH RPC call: eth_getBlockByHash
Sourcepub async fn block_by_number(
&self,
number: BlockNumber,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn block_by_number( &self, number: BlockNumber, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Returns block with given number.
Handler for ETH RPC call: eth_getBlockByNumber
Sourcepub async fn block_by_number_full(
&self,
number: BlockNumber,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn block_by_number_full( &self, number: BlockNumber, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Returns a full block with given number
Handler for ETH RPC call: eth_getBlockByNumber
Sourcepub async fn transaction_count(
&self,
address: Address,
block_number: Option<BlockId>,
) -> Result<U256, BlockchainError>
pub async fn transaction_count( &self, address: Address, block_number: Option<BlockId>, ) -> Result<U256, BlockchainError>
Returns the number of transactions sent from given address at given time (block number).
Also checks the pending transactions if block_number
is
BlockId::Number(BlockNumber::Pending)
Handler for ETH RPC call: eth_getTransactionCount
Sourcepub async fn block_transaction_count_by_hash(
&self,
hash: B256,
) -> Result<Option<U256>, BlockchainError>
pub async fn block_transaction_count_by_hash( &self, hash: B256, ) -> Result<Option<U256>, BlockchainError>
Returns the number of transactions in a block with given hash.
Handler for ETH RPC call: eth_getBlockTransactionCountByHash
Sourcepub async fn block_transaction_count_by_number(
&self,
block_number: BlockNumber,
) -> Result<Option<U256>, BlockchainError>
pub async fn block_transaction_count_by_number( &self, block_number: BlockNumber, ) -> Result<Option<U256>, BlockchainError>
Returns the number of transactions in a block with given block number.
Handler for ETH RPC call: eth_getBlockTransactionCountByNumber
Sourcepub async fn block_uncles_count_by_hash(
&self,
hash: B256,
) -> Result<U256, BlockchainError>
pub async fn block_uncles_count_by_hash( &self, hash: B256, ) -> Result<U256, BlockchainError>
Returns the number of uncles in a block with given hash.
Handler for ETH RPC call: eth_getUncleCountByBlockHash
Sourcepub async fn block_uncles_count_by_number(
&self,
block_number: BlockNumber,
) -> Result<U256, BlockchainError>
pub async fn block_uncles_count_by_number( &self, block_number: BlockNumber, ) -> Result<U256, BlockchainError>
Returns the number of uncles in a block with given block number.
Handler for ETH RPC call: eth_getUncleCountByBlockNumber
Sourcepub async fn get_code(
&self,
address: Address,
block_number: Option<BlockId>,
) -> Result<Bytes, BlockchainError>
pub async fn get_code( &self, address: Address, block_number: Option<BlockId>, ) -> Result<Bytes, BlockchainError>
Returns the code at given address at given time (block number).
Handler for ETH RPC call: eth_getCode
Sourcepub async fn get_proof(
&self,
address: Address,
keys: Vec<B256>,
block_number: Option<BlockId>,
) -> Result<EIP1186AccountProofResponse, BlockchainError>
pub async fn get_proof( &self, address: Address, keys: Vec<B256>, block_number: Option<BlockId>, ) -> Result<EIP1186AccountProofResponse, BlockchainError>
Returns the account and storage values of the specified account including the Merkle-proof. This call can be used to verify that the data you are pulling from is not tampered with.
Handler for ETH RPC call: eth_getProof
Sourcepub async fn sign_typed_data(
&self,
_address: Address,
_data: Value,
) -> Result<String, BlockchainError>
pub async fn sign_typed_data( &self, _address: Address, _data: Value, ) -> Result<String, BlockchainError>
Signs data via EIP-712.
Handler for ETH RPC call: eth_signTypedData
Sourcepub async fn sign_typed_data_v3(
&self,
_address: Address,
_data: Value,
) -> Result<String, BlockchainError>
pub async fn sign_typed_data_v3( &self, _address: Address, _data: Value, ) -> Result<String, BlockchainError>
Signs data via EIP-712.
Handler for ETH RPC call: eth_signTypedData_v3
Sourcepub async fn sign_typed_data_v4(
&self,
address: Address,
data: &TypedData,
) -> Result<String, BlockchainError>
pub async fn sign_typed_data_v4( &self, address: Address, data: &TypedData, ) -> Result<String, BlockchainError>
Signs data via EIP-712, and includes full support of arrays and recursive data structures.
Handler for ETH RPC call: eth_signTypedData_v4
Sourcepub async fn sign(
&self,
address: Address,
content: impl AsRef<[u8]>,
) -> Result<String, BlockchainError>
pub async fn sign( &self, address: Address, content: impl AsRef<[u8]>, ) -> Result<String, BlockchainError>
The sign method calculates an Ethereum specific signature
Handler for ETH RPC call: eth_sign
Sourcepub async fn sign_transaction(
&self,
request: WithOtherFields<TransactionRequest>,
) -> Result<String, BlockchainError>
pub async fn sign_transaction( &self, request: WithOtherFields<TransactionRequest>, ) -> Result<String, BlockchainError>
Signs a transaction
Handler for ETH RPC call: eth_signTransaction
Sourcepub async fn send_transaction(
&self,
request: WithOtherFields<TransactionRequest>,
) -> Result<TxHash, BlockchainError>
pub async fn send_transaction( &self, request: WithOtherFields<TransactionRequest>, ) -> Result<TxHash, BlockchainError>
Sends a transaction
Handler for ETH RPC call: eth_sendTransaction
Sourcepub async fn send_raw_transaction(
&self,
tx: Bytes,
) -> Result<TxHash, BlockchainError>
pub async fn send_raw_transaction( &self, tx: Bytes, ) -> Result<TxHash, BlockchainError>
Sends signed transaction, returning its hash.
Handler for ETH RPC call: eth_sendRawTransaction
Sourcepub async fn call(
&self,
request: WithOtherFields<TransactionRequest>,
block_number: Option<BlockId>,
overrides: Option<StateOverride>,
) -> Result<Bytes, BlockchainError>
pub async fn call( &self, request: WithOtherFields<TransactionRequest>, block_number: Option<BlockId>, overrides: Option<StateOverride>, ) -> Result<Bytes, BlockchainError>
Call contract, returning the output data.
Handler for ETH RPC call: eth_call
Sourcepub async fn create_access_list(
&self,
request: WithOtherFields<TransactionRequest>,
block_number: Option<BlockId>,
) -> Result<AccessListResult, BlockchainError>
pub async fn create_access_list( &self, request: WithOtherFields<TransactionRequest>, block_number: Option<BlockId>, ) -> Result<AccessListResult, BlockchainError>
This method creates an EIP2930 type accessList based on a given Transaction. The accessList contains all storage slots and addresses read and written by the transaction, except for the sender account and the precompiles.
It returns list of addresses and storage keys used by the transaction, plus the gas consumed when the access list is added. That is, it gives you the list of addresses and storage keys that will be used by that transaction, plus the gas consumed if the access list is included. Like eth_estimateGas, this is an estimation; the list could change when the transaction is actually mined. Adding an accessList to your transaction does not necessary result in lower gas usage compared to a transaction without an access list.
Handler for ETH RPC call: eth_createAccessList
Sourcepub async fn estimate_gas(
&self,
request: WithOtherFields<TransactionRequest>,
block_number: Option<BlockId>,
overrides: Option<StateOverride>,
) -> Result<U256, BlockchainError>
pub async fn estimate_gas( &self, request: WithOtherFields<TransactionRequest>, block_number: Option<BlockId>, overrides: Option<StateOverride>, ) -> Result<U256, BlockchainError>
Estimate gas needed for execution of given contract. If no block parameter is given, it will use the pending block by default
Handler for ETH RPC call: eth_estimateGas
Sourcepub async fn transaction_by_hash(
&self,
hash: B256,
) -> Result<Option<AnyRpcTransaction>, BlockchainError>
pub async fn transaction_by_hash( &self, hash: B256, ) -> Result<Option<AnyRpcTransaction>, BlockchainError>
Get transaction by its hash.
This will check the storage for a matching transaction, if no transaction exists in storage this will also scan the mempool for a matching pending transaction
Handler for ETH RPC call: eth_getTransactionByHash
Sourcepub async fn transaction_by_block_hash_and_index(
&self,
hash: B256,
index: Index,
) -> Result<Option<AnyRpcTransaction>, BlockchainError>
pub async fn transaction_by_block_hash_and_index( &self, hash: B256, index: Index, ) -> Result<Option<AnyRpcTransaction>, BlockchainError>
Returns transaction at given block hash and index.
Handler for ETH RPC call: eth_getTransactionByBlockHashAndIndex
Sourcepub async fn transaction_by_block_number_and_index(
&self,
block: BlockNumber,
idx: Index,
) -> Result<Option<AnyRpcTransaction>, BlockchainError>
pub async fn transaction_by_block_number_and_index( &self, block: BlockNumber, idx: Index, ) -> Result<Option<AnyRpcTransaction>, BlockchainError>
Returns transaction by given block number and index.
Handler for ETH RPC call: eth_getTransactionByBlockNumberAndIndex
Sourcepub async fn transaction_receipt(
&self,
hash: B256,
) -> Result<Option<ReceiptResponse>, BlockchainError>
pub async fn transaction_receipt( &self, hash: B256, ) -> Result<Option<ReceiptResponse>, BlockchainError>
Returns transaction receipt by transaction hash.
Handler for ETH RPC call: eth_getTransactionReceipt
Sourcepub async fn block_receipts(
&self,
number: BlockId,
) -> Result<Option<Vec<ReceiptResponse>>, BlockchainError>
pub async fn block_receipts( &self, number: BlockId, ) -> Result<Option<Vec<ReceiptResponse>>, BlockchainError>
Returns block receipts by block number.
Handler for ETH RPC call: eth_getBlockReceipts
Sourcepub async fn uncle_by_block_hash_and_index(
&self,
block_hash: B256,
idx: Index,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn uncle_by_block_hash_and_index( &self, block_hash: B256, idx: Index, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Returns an uncles at given block and index.
Handler for ETH RPC call: eth_getUncleByBlockHashAndIndex
Sourcepub async fn uncle_by_block_number_and_index(
&self,
block_number: BlockNumber,
idx: Index,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn uncle_by_block_number_and_index( &self, block_number: BlockNumber, idx: Index, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Returns an uncles at given block and index.
Handler for ETH RPC call: eth_getUncleByBlockNumberAndIndex
Sourcepub async fn logs(&self, filter: Filter) -> Result<Vec<Log>, BlockchainError>
pub async fn logs(&self, filter: Filter) -> Result<Vec<Log>, BlockchainError>
Returns logs matching given filter object.
Handler for ETH RPC call: eth_getLogs
Sourcepub fn work(&self) -> Result<Work, BlockchainError>
pub fn work(&self) -> Result<Work, BlockchainError>
Returns the hash of the current block, the seedHash, and the boundary condition to be met.
Handler for ETH RPC call: eth_getWork
Sourcepub fn syncing(&self) -> Result<bool, BlockchainError>
pub fn syncing(&self) -> Result<bool, BlockchainError>
Returns the sync status, always be fails.
Handler for ETH RPC call: eth_syncing
Sourcepub fn submit_work(
&self,
_: B64,
_: B256,
_: B256,
) -> Result<bool, BlockchainError>
pub fn submit_work( &self, _: B64, _: B256, _: B256, ) -> Result<bool, BlockchainError>
Used for submitting a proof-of-work solution.
Handler for ETH RPC call: eth_submitWork
Sourcepub fn submit_hashrate(&self, _: U256, _: B256) -> Result<bool, BlockchainError>
pub fn submit_hashrate(&self, _: U256, _: B256) -> Result<bool, BlockchainError>
Used for submitting mining hashrate.
Handler for ETH RPC call: eth_submitHashrate
Sourcepub async fn fee_history(
&self,
block_count: U256,
newest_block: BlockNumber,
reward_percentiles: Vec<f64>,
) -> Result<FeeHistory, BlockchainError>
pub async fn fee_history( &self, block_count: U256, newest_block: BlockNumber, reward_percentiles: Vec<f64>, ) -> Result<FeeHistory, BlockchainError>
Introduced in EIP-1559 for getting information on the appropriate priority fee to use.
Handler for ETH RPC call: eth_feeHistory
Sourcepub fn max_priority_fee_per_gas(&self) -> Result<U256, BlockchainError>
pub fn max_priority_fee_per_gas(&self) -> Result<U256, BlockchainError>
Introduced in EIP-1159, a Geth-specific and simplified priority fee oracle. Leverages the already existing fee history cache.
Returns a suggestion for a gas tip cap for dynamic fee transactions.
Handler for ETH RPC call: eth_maxPriorityFeePerGas
Sourcefn lowest_suggestion_tip(&self) -> u128
fn lowest_suggestion_tip(&self) -> u128
Returns the suggested fee cap.
Returns at least MIN_SUGGESTED_PRIORITY_FEE
Sourcepub async fn new_filter(
&self,
filter: Filter,
) -> Result<String, BlockchainError>
pub async fn new_filter( &self, filter: Filter, ) -> Result<String, BlockchainError>
Creates a filter object, based on filter options, to notify when the state changes (logs).
Handler for ETH RPC call: eth_newFilter
Sourcepub async fn new_block_filter(&self) -> Result<String, BlockchainError>
pub async fn new_block_filter(&self) -> Result<String, BlockchainError>
Creates a filter in the node, to notify when a new block arrives.
Handler for ETH RPC call: eth_newBlockFilter
Sourcepub async fn new_pending_transaction_filter(
&self,
) -> Result<String, BlockchainError>
pub async fn new_pending_transaction_filter( &self, ) -> Result<String, BlockchainError>
Creates a filter in the node, to notify when new pending transactions arrive.
Handler for ETH RPC call: eth_newPendingTransactionFilter
Sourcepub async fn get_filter_changes(&self, id: &str) -> ResponseResult
pub async fn get_filter_changes(&self, id: &str) -> ResponseResult
Polling method for a filter, which returns an array of logs which occurred since last poll.
Handler for ETH RPC call: eth_getFilterChanges
Sourcepub async fn get_filter_logs(
&self,
id: &str,
) -> Result<Vec<Log>, BlockchainError>
pub async fn get_filter_logs( &self, id: &str, ) -> Result<Vec<Log>, BlockchainError>
Returns an array of all logs matching filter with given id.
Handler for ETH RPC call: eth_getFilterLogs
Sourcepub async fn uninstall_filter(&self, id: &str) -> Result<bool, BlockchainError>
pub async fn uninstall_filter(&self, id: &str) -> Result<bool, BlockchainError>
Handler for ETH RPC call: eth_uninstallFilter
Sourcepub async fn raw_transaction(
&self,
hash: B256,
) -> Result<Option<Bytes>, BlockchainError>
pub async fn raw_transaction( &self, hash: B256, ) -> Result<Option<Bytes>, BlockchainError>
Returns EIP-2718 encoded raw transaction
Handler for RPC call: debug_getRawTransaction
Sourcepub async fn raw_transaction_by_block_hash_and_index(
&self,
block_hash: B256,
index: Index,
) -> Result<Option<Bytes>, BlockchainError>
pub async fn raw_transaction_by_block_hash_and_index( &self, block_hash: B256, index: Index, ) -> Result<Option<Bytes>, BlockchainError>
Returns EIP-2718 encoded raw transaction by block hash and index
Handler for RPC call: eth_getRawTransactionByBlockHashAndIndex
Sourcepub async fn raw_transaction_by_block_number_and_index(
&self,
block_number: BlockNumber,
index: Index,
) -> Result<Option<Bytes>, BlockchainError>
pub async fn raw_transaction_by_block_number_and_index( &self, block_number: BlockNumber, index: Index, ) -> Result<Option<Bytes>, BlockchainError>
Returns EIP-2718 encoded raw transaction by block number and index
Handler for RPC call: eth_getRawTransactionByBlockNumberAndIndex
Sourcepub async fn debug_trace_transaction(
&self,
tx_hash: B256,
opts: GethDebugTracingOptions,
) -> Result<GethTrace, BlockchainError>
pub async fn debug_trace_transaction( &self, tx_hash: B256, opts: GethDebugTracingOptions, ) -> Result<GethTrace, BlockchainError>
Returns traces for the transaction hash for geth’s tracing endpoint
Handler for RPC call: debug_traceTransaction
Sourcepub async fn debug_trace_call(
&self,
request: WithOtherFields<TransactionRequest>,
block_number: Option<BlockId>,
opts: GethDebugTracingCallOptions,
) -> Result<GethTrace, BlockchainError>
pub async fn debug_trace_call( &self, request: WithOtherFields<TransactionRequest>, block_number: Option<BlockId>, opts: GethDebugTracingCallOptions, ) -> Result<GethTrace, BlockchainError>
Returns traces for the transaction for geth’s tracing endpoint
Handler for RPC call: debug_traceCall
Sourcepub async fn trace_transaction(
&self,
tx_hash: B256,
) -> Result<Vec<LocalizedTransactionTrace>, BlockchainError>
pub async fn trace_transaction( &self, tx_hash: B256, ) -> Result<Vec<LocalizedTransactionTrace>, BlockchainError>
Returns traces for the transaction hash via parity’s tracing endpoint
Handler for RPC call: trace_transaction
Sourcepub async fn trace_block(
&self,
block: BlockNumber,
) -> Result<Vec<LocalizedTransactionTrace>, BlockchainError>
pub async fn trace_block( &self, block: BlockNumber, ) -> Result<Vec<LocalizedTransactionTrace>, BlockchainError>
Returns traces for the transaction hash via parity’s tracing endpoint
Handler for RPC call: trace_block
Sourcepub async fn trace_filter(
&self,
filter: TraceFilter,
) -> Result<Vec<LocalizedTransactionTrace>, BlockchainError>
pub async fn trace_filter( &self, filter: TraceFilter, ) -> Result<Vec<LocalizedTransactionTrace>, BlockchainError>
Returns filtered traces over blocks
Handler for RPC call: trace_filter
Source§impl EthApi
impl EthApi
Sourcepub async fn anvil_impersonate_account(
&self,
address: Address,
) -> Result<(), BlockchainError>
pub async fn anvil_impersonate_account( &self, address: Address, ) -> Result<(), BlockchainError>
Send transactions impersonating specific account and contract addresses.
Handler for ETH RPC call: anvil_impersonateAccount
Sourcepub async fn anvil_stop_impersonating_account(
&self,
address: Address,
) -> Result<(), BlockchainError>
pub async fn anvil_stop_impersonating_account( &self, address: Address, ) -> Result<(), BlockchainError>
Stops impersonating an account if previously set with anvil_impersonateAccount
.
Handler for ETH RPC call: anvil_stopImpersonatingAccount
Sourcepub async fn anvil_auto_impersonate_account(
&self,
enabled: bool,
) -> Result<(), BlockchainError>
pub async fn anvil_auto_impersonate_account( &self, enabled: bool, ) -> Result<(), BlockchainError>
If set to true will make every account impersonated
Handler for ETH RPC call: anvil_autoImpersonateAccount
Sourcepub fn anvil_get_auto_mine(&self) -> Result<bool, BlockchainError>
pub fn anvil_get_auto_mine(&self) -> Result<bool, BlockchainError>
Returns true if auto mining is enabled, and false.
Handler for ETH RPC call: anvil_getAutomine
Sourcepub fn anvil_get_interval_mining(&self) -> Result<Option<u64>, BlockchainError>
pub fn anvil_get_interval_mining(&self) -> Result<Option<u64>, BlockchainError>
Returns the value of mining interval, if set.
Handler for ETH RPC call: anvil_getIntervalMining
.
Sourcepub async fn anvil_set_auto_mine(
&self,
enable_automine: bool,
) -> Result<(), BlockchainError>
pub async fn anvil_set_auto_mine( &self, enable_automine: bool, ) -> Result<(), BlockchainError>
Enables or disables, based on the single boolean argument, the automatic mining of new blocks with each new transaction submitted to the network.
Handler for ETH RPC call: evm_setAutomine
Sourcepub async fn anvil_mine(
&self,
num_blocks: Option<U256>,
interval: Option<U256>,
) -> Result<(), BlockchainError>
pub async fn anvil_mine( &self, num_blocks: Option<U256>, interval: Option<U256>, ) -> Result<(), BlockchainError>
Mines a series of blocks.
Handler for ETH RPC call: anvil_mine
Sourcepub fn anvil_set_interval_mining(
&self,
secs: u64,
) -> Result<(), BlockchainError>
pub fn anvil_set_interval_mining( &self, secs: u64, ) -> Result<(), BlockchainError>
Sets the mining behavior to interval with the given interval (seconds)
Handler for ETH RPC call: evm_setIntervalMining
Sourcepub async fn anvil_drop_transaction(
&self,
tx_hash: B256,
) -> Result<Option<B256>, BlockchainError>
pub async fn anvil_drop_transaction( &self, tx_hash: B256, ) -> Result<Option<B256>, BlockchainError>
Removes transactions from the pool
Handler for RPC call: anvil_dropTransaction
Sourcepub async fn anvil_drop_all_transactions(&self) -> Result<(), BlockchainError>
pub async fn anvil_drop_all_transactions(&self) -> Result<(), BlockchainError>
Removes all transactions from the pool
Handler for RPC call: anvil_dropAllTransactions
Sourcepub async fn anvil_reset(
&self,
forking: Option<Forking>,
) -> Result<(), BlockchainError>
pub async fn anvil_reset( &self, forking: Option<Forking>, ) -> Result<(), BlockchainError>
Reset the fork to a fresh forked state, and optionally update the fork config.
If forking
is None
then this will disable forking entirely.
Handler for RPC call: anvil_reset
pub async fn anvil_set_chain_id( &self, chain_id: u64, ) -> Result<(), BlockchainError>
Sourcepub async fn anvil_set_balance(
&self,
address: Address,
balance: U256,
) -> Result<(), BlockchainError>
pub async fn anvil_set_balance( &self, address: Address, balance: U256, ) -> Result<(), BlockchainError>
Modifies the balance of an account.
Handler for RPC call: anvil_setBalance
Sourcepub async fn anvil_set_code(
&self,
address: Address,
code: Bytes,
) -> Result<(), BlockchainError>
pub async fn anvil_set_code( &self, address: Address, code: Bytes, ) -> Result<(), BlockchainError>
Sets the code of a contract.
Handler for RPC call: anvil_setCode
Sourcepub async fn anvil_set_nonce(
&self,
address: Address,
nonce: U256,
) -> Result<(), BlockchainError>
pub async fn anvil_set_nonce( &self, address: Address, nonce: U256, ) -> Result<(), BlockchainError>
Sets the nonce of an address.
Handler for RPC call: anvil_setNonce
Sourcepub async fn anvil_set_storage_at(
&self,
address: Address,
slot: U256,
val: B256,
) -> Result<bool, BlockchainError>
pub async fn anvil_set_storage_at( &self, address: Address, slot: U256, val: B256, ) -> Result<bool, BlockchainError>
Writes a single slot of the account’s storage.
Handler for RPC call: anvil_setStorageAt
Sourcepub async fn anvil_set_logging(
&self,
enable: bool,
) -> Result<(), BlockchainError>
pub async fn anvil_set_logging( &self, enable: bool, ) -> Result<(), BlockchainError>
Enable or disable logging.
Handler for RPC call: anvil_setLoggingEnabled
Sourcepub async fn anvil_set_min_gas_price(
&self,
gas: U256,
) -> Result<(), BlockchainError>
pub async fn anvil_set_min_gas_price( &self, gas: U256, ) -> Result<(), BlockchainError>
Set the minimum gas price for the node.
Handler for RPC call: anvil_setMinGasPrice
Sourcepub async fn anvil_set_next_block_base_fee_per_gas(
&self,
basefee: U256,
) -> Result<(), BlockchainError>
pub async fn anvil_set_next_block_base_fee_per_gas( &self, basefee: U256, ) -> Result<(), BlockchainError>
Sets the base fee of the next block.
Handler for RPC call: anvil_setNextBlockBaseFeePerGas
Sourcepub async fn anvil_set_coinbase(
&self,
address: Address,
) -> Result<(), BlockchainError>
pub async fn anvil_set_coinbase( &self, address: Address, ) -> Result<(), BlockchainError>
Sets the coinbase address.
Handler for RPC call: anvil_setCoinbase
Sourcepub async fn anvil_dump_state(
&self,
preserve_historical_states: Option<bool>,
) -> Result<Bytes, BlockchainError>
pub async fn anvil_dump_state( &self, preserve_historical_states: Option<bool>, ) -> Result<Bytes, BlockchainError>
Create a buffer that represents all state on the chain, which can be loaded to separate
process by calling anvil_loadState
Handler for RPC call: anvil_dumpState
Sourcepub async fn serialized_state(
&self,
preserve_historical_states: bool,
) -> Result<SerializableState, BlockchainError>
pub async fn serialized_state( &self, preserve_historical_states: bool, ) -> Result<SerializableState, BlockchainError>
Returns the current state
Sourcepub async fn anvil_load_state(
&self,
buf: Bytes,
) -> Result<bool, BlockchainError>
pub async fn anvil_load_state( &self, buf: Bytes, ) -> Result<bool, BlockchainError>
Append chain state buffer to current chain. Will overwrite any conflicting addresses or storage.
Handler for RPC call: anvil_loadState
Sourcepub async fn anvil_node_info(&self) -> Result<NodeInfo, BlockchainError>
pub async fn anvil_node_info(&self) -> Result<NodeInfo, BlockchainError>
Retrieves the Anvil node configuration params.
Handler for RPC call: anvil_nodeInfo
Sourcepub async fn anvil_metadata(&self) -> Result<Metadata, BlockchainError>
pub async fn anvil_metadata(&self) -> Result<Metadata, BlockchainError>
Retrieves metadata about the Anvil instance.
Handler for RPC call: anvil_metadata
pub async fn anvil_remove_pool_transactions( &self, address: Address, ) -> Result<(), BlockchainError>
Sourcepub async fn anvil_reorg(
&self,
options: ReorgOptions,
) -> Result<(), BlockchainError>
pub async fn anvil_reorg( &self, options: ReorgOptions, ) -> Result<(), BlockchainError>
Reorg the chain to a specific depth and mine new blocks back to the canonical height.
e.g depth = 3 A -> B -> C -> D -> E A -> B -> C’ -> D’ -> E’
Depth specifies the height to reorg the chain back to. Depth must not exceed the current chain height, i.e. can’t reorg past the genesis block.
Optionally supply a list of transaction and block pairs that will populate the reorged blocks. The maximum block number of the pairs must not exceed the specified depth.
Handler for RPC call: anvil_reorg
Sourcepub async fn evm_snapshot(&self) -> Result<U256, BlockchainError>
pub async fn evm_snapshot(&self) -> Result<U256, BlockchainError>
Snapshot the state of the blockchain at the current block.
Handler for RPC call: evm_snapshot
Sourcepub async fn evm_revert(&self, id: U256) -> Result<bool, BlockchainError>
pub async fn evm_revert(&self, id: U256) -> Result<bool, BlockchainError>
Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to.
Handler for RPC call: evm_revert
Sourcepub async fn evm_increase_time(
&self,
seconds: U256,
) -> Result<i64, BlockchainError>
pub async fn evm_increase_time( &self, seconds: U256, ) -> Result<i64, BlockchainError>
Jump forward in time by the given amount of time, in seconds.
Handler for RPC call: evm_increaseTime
Sourcepub fn evm_set_next_block_timestamp(
&self,
seconds: u64,
) -> Result<(), BlockchainError>
pub fn evm_set_next_block_timestamp( &self, seconds: u64, ) -> Result<(), BlockchainError>
Similar to evm_increaseTime
but takes the exact timestamp that you want in the next block
Handler for RPC call: evm_setNextBlockTimestamp
Sourcepub fn evm_set_time(&self, timestamp: u64) -> Result<u64, BlockchainError>
pub fn evm_set_time(&self, timestamp: u64) -> Result<u64, BlockchainError>
Sets the specific timestamp and returns the number of seconds between the given timestamp and the current time.
Handler for RPC call: evm_setTime
Sourcepub fn evm_set_block_gas_limit(
&self,
gas_limit: U256,
) -> Result<bool, BlockchainError>
pub fn evm_set_block_gas_limit( &self, gas_limit: U256, ) -> Result<bool, BlockchainError>
Set the next block gas limit
Handler for RPC call: evm_setBlockGasLimit
Sourcepub fn evm_set_block_timestamp_interval(
&self,
seconds: u64,
) -> Result<(), BlockchainError>
pub fn evm_set_block_timestamp_interval( &self, seconds: u64, ) -> Result<(), BlockchainError>
Sets an interval for the block timestamp
Handler for RPC call: anvil_setBlockTimestampInterval
Sourcepub fn evm_remove_block_timestamp_interval(
&self,
) -> Result<bool, BlockchainError>
pub fn evm_remove_block_timestamp_interval( &self, ) -> Result<bool, BlockchainError>
Sets an interval for the block timestamp
Handler for RPC call: anvil_removeBlockTimestampInterval
Sourcepub async fn evm_mine(
&self,
opts: Option<MineOptions>,
) -> Result<String, BlockchainError>
pub async fn evm_mine( &self, opts: Option<MineOptions>, ) -> Result<String, BlockchainError>
Mine blocks, instantly.
Handler for RPC call: evm_mine
This will mine the blocks regardless of the configured mining mode.
Note: ganache returns 0x0
here as placeholder for additional meta-data in the future.
Sourcepub async fn evm_mine_detailed(
&self,
opts: Option<MineOptions>,
) -> Result<Vec<AnyRpcBlock>, BlockchainError>
pub async fn evm_mine_detailed( &self, opts: Option<MineOptions>, ) -> Result<Vec<AnyRpcBlock>, BlockchainError>
Mine blocks, instantly and return the mined blocks.
Handler for RPC call: evm_mine_detailed
This will mine the blocks regardless of the configured mining mode.
Note: This behaves exactly as Self::evm_mine but returns different output, for
compatibility reasons, this is a separate call since evm_mine
is not an anvil original.
and ganache
may change the 0x0
placeholder.
Sourcepub fn anvil_set_block(&self, block_number: U256) -> Result<(), BlockchainError>
pub fn anvil_set_block(&self, block_number: U256) -> Result<(), BlockchainError>
Sets the reported block number
Handler for ETH RPC call: anvil_setBlock
Sourcepub fn anvil_set_rpc_url(&self, url: String) -> Result<(), BlockchainError>
pub fn anvil_set_rpc_url(&self, url: String) -> Result<(), BlockchainError>
Sets the backend rpc url
Handler for ETH RPC call: anvil_setRpcUrl
Sourcepub async fn anvil_enable_traces(&self) -> Result<(), BlockchainError>
pub async fn anvil_enable_traces(&self) -> Result<(), BlockchainError>
Turn on call traces for transactions that are returned to the user when they execute a transaction (instead of just txhash/receipt)
Handler for ETH RPC call: anvil_enableTraces
Sourcepub async fn eth_send_unsigned_transaction(
&self,
request: WithOtherFields<TransactionRequest>,
) -> Result<TxHash, BlockchainError>
pub async fn eth_send_unsigned_transaction( &self, request: WithOtherFields<TransactionRequest>, ) -> Result<TxHash, BlockchainError>
Execute a transaction regardless of signature status
Handler for ETH RPC call: eth_sendUnsignedTransaction
Sourcepub async fn txpool_status(&self) -> Result<TxpoolStatus, BlockchainError>
pub async fn txpool_status(&self) -> Result<TxpoolStatus, BlockchainError>
Returns the number of transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only. Ref: Here
Handler for ETH RPC call: txpool_status
Sourcepub async fn txpool_inspect(&self) -> Result<TxpoolInspect, BlockchainError>
pub async fn txpool_inspect(&self) -> Result<TxpoolInspect, BlockchainError>
Returns a summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.
See here for more details
Handler for ETH RPC call: txpool_inspect
Sourcepub async fn txpool_content(
&self,
) -> Result<TxpoolContent<AnyRpcTransaction>, BlockchainError>
pub async fn txpool_content( &self, ) -> Result<TxpoolContent<AnyRpcTransaction>, BlockchainError>
Returns the details of all transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.
See here for more details
Handler for ETH RPC call: txpool_inspect
Source§impl EthApi
impl EthApi
Sourcepub fn get_capabilities(&self) -> Result<WalletCapabilities, BlockchainError>
pub fn get_capabilities(&self) -> Result<WalletCapabilities, BlockchainError>
Get the capabilities of the wallet.
See also EIP-5792.
pub async fn wallet_send_transaction( &self, request: WithOtherFields<TransactionRequest>, ) -> Result<TxHash, BlockchainError>
Sourcepub fn anvil_add_capability(
&self,
address: Address,
) -> Result<(), BlockchainError>
pub fn anvil_add_capability( &self, address: Address, ) -> Result<(), BlockchainError>
Add an address to the delegation capability of wallet.
This entails that the executor will now be able to sponsor transactions to this address.
pub fn anvil_set_executor( &self, executor_pk: String, ) -> Result<Address, BlockchainError>
Source§impl EthApi
impl EthApi
Sourceasync fn on_blocking_task<C, F, R>(&self, c: C) -> Result<R, BlockchainError>
async fn on_blocking_task<C, F, R>(&self, c: C) -> Result<R, BlockchainError>
Executes the future on a new blocking task.
Sourceasync fn do_evm_mine(
&self,
opts: Option<MineOptions>,
) -> Result<u64, BlockchainError>
async fn do_evm_mine( &self, opts: Option<MineOptions>, ) -> Result<u64, BlockchainError>
Executes the evm_mine
and returns the number of blocks mined
async fn do_estimate_gas( &self, request: WithOtherFields<TransactionRequest>, block_number: Option<BlockId>, overrides: Option<StateOverride>, ) -> Result<u128, BlockchainError>
Sourcefn do_estimate_gas_with_state(
&self,
request: WithOtherFields<TransactionRequest>,
state: &dyn DatabaseRef<Error = DatabaseError>,
block_env: BlockEnv,
) -> Result<u128, BlockchainError>
fn do_estimate_gas_with_state( &self, request: WithOtherFields<TransactionRequest>, state: &dyn DatabaseRef<Error = DatabaseError>, block_env: BlockEnv, ) -> Result<u128, BlockchainError>
Estimates the gas usage of the request
with the state.
This will execute the transaction request and find the best gas limit via binary search.
Sourcepub fn set_transaction_order(&self, order: TransactionOrder)
pub fn set_transaction_order(&self, order: TransactionOrder)
Updates the TransactionOrder
Sourcefn transaction_priority(&self, tx: &TypedTransaction) -> TransactionPriority
fn transaction_priority(&self, tx: &TypedTransaction) -> TransactionPriority
Returns the priority of the transaction based on the current TransactionOrder
Sourcepub fn get_fork(&self) -> Option<ClientFork>
pub fn get_fork(&self) -> Option<ClientFork>
Returns the configured fork, if any.
Sourcepub fn instance_id(&self) -> B256
pub fn instance_id(&self) -> B256
Returns the current instance’s ID.
Sourcepub fn reset_instance_id(&self)
pub fn reset_instance_id(&self)
Resets the instance ID.
Sourcepub fn get_signer(&self, address: Address) -> Option<&Box<dyn Signer>>
pub fn get_signer(&self, address: Address) -> Option<&Box<dyn Signer>>
Returns the first signer that can sign for the given address
Sourcepub fn new_block_notifications(&self) -> NewBlockNotifications
pub fn new_block_notifications(&self) -> NewBlockNotifications
Returns a new block event stream that yields Notifications when a new block was added
Sourcepub fn new_ready_transactions(&self) -> Receiver<TxHash>
pub fn new_ready_transactions(&self) -> Receiver<TxHash>
Returns a new listeners for ready transactions
Sourcepub fn storage_info(&self) -> StorageInfo
pub fn storage_info(&self) -> StorageInfo
Returns a new accessor for certain storage elements
Sourceasync fn pending_block(&self) -> AnyRpcBlock
async fn pending_block(&self) -> AnyRpcBlock
Returns the pending block with tx hashes
Sourceasync fn pending_block_full(&self) -> Option<AnyRpcBlock>
async fn pending_block_full(&self) -> Option<AnyRpcBlock>
Returns the full pending block with Transaction
objects
fn build_typed_tx_request( &self, request: WithOtherFields<TransactionRequest>, nonce: u64, ) -> Result<TypedTransactionRequest, BlockchainError>
Sourcepub fn is_impersonated(&self, addr: Address) -> bool
pub fn is_impersonated(&self, addr: Address) -> bool
Returns true if the addr
is currently impersonated
Sourcefn impersonated_signature(&self, request: &TypedTransactionRequest) -> Signature
fn impersonated_signature(&self, request: &TypedTransactionRequest) -> Signature
The signature used to bypass signing via the eth_sendUnsignedTransaction
cheat RPC
Sourceasync fn get_transaction_count(
&self,
address: Address,
block_number: Option<BlockId>,
) -> Result<u64, BlockchainError>
async fn get_transaction_count( &self, address: Address, block_number: Option<BlockId>, ) -> Result<u64, BlockchainError>
Returns the nonce of the address
depending on the block_number
Sourceasync fn request_nonce(
&self,
request: &TransactionRequest,
from: Address,
) -> Result<(u64, u64), BlockchainError>
async fn request_nonce( &self, request: &TransactionRequest, from: Address, ) -> Result<(u64, u64), BlockchainError>
Returns the nonce for this request
This returns a tuple of (request nonce, highest nonce)
If the nonce field of the request
is None
then the tuple will be (highest nonce, highest nonce)
.
This will also check the tx pool for pending transactions from the sender.
Sourcefn add_pending_transaction(
&self,
pending_transaction: PendingTransaction,
requires: Vec<TxMarker>,
provides: Vec<TxMarker>,
) -> Result<TxHash, BlockchainError>
fn add_pending_transaction( &self, pending_transaction: PendingTransaction, requires: Vec<TxMarker>, provides: Vec<TxMarker>, ) -> Result<TxHash, BlockchainError>
Adds the given transaction to the pool
Sourcepub async fn state_root(&self) -> Option<B256>
pub async fn state_root(&self) -> Option<B256>
Returns the current state root
Sourcefn ensure_typed_transaction_supported(
&self,
tx: &TypedTransaction,
) -> Result<(), BlockchainError>
fn ensure_typed_transaction_supported( &self, tx: &TypedTransaction, ) -> Result<(), BlockchainError>
additional validation against hardfork
Source§impl EthApi
impl EthApi
Sourcepub async fn erigon_get_header_by_number(
&self,
number: BlockNumber,
) -> Result<Option<AnyRpcBlock>, BlockchainError>
pub async fn erigon_get_header_by_number( &self, number: BlockNumber, ) -> Result<Option<AnyRpcBlock>, BlockchainError>
Otterscan currently requires this endpoint, even though it’s not part of the ots_*
.
Ref: https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/useProvider.ts#L71
As a faster alternative to eth_getBlockByNumber
(by excluding uncle block
information), which is not relevant in the context of an anvil node
Sourcepub async fn ots_get_api_level(&self) -> Result<u64, BlockchainError>
pub async fn ots_get_api_level(&self) -> Result<u64, BlockchainError>
As per the latest Otterscan source code, at least version 8 is needed. Ref: https://github.com/otterscan/otterscan/blob/071d8c55202badf01804f6f8d53ef9311d4a9e47/src/params.ts#L1C2-L1C2
Sourcepub async fn ots_get_internal_operations(
&self,
hash: B256,
) -> Result<Vec<InternalOperation>, BlockchainError>
pub async fn ots_get_internal_operations( &self, hash: B256, ) -> Result<Vec<InternalOperation>, BlockchainError>
Trace internal ETH transfers, contracts creation (CREATE/CREATE2) and self-destructs for a certain transaction.
Sourcepub async fn ots_has_code(
&self,
address: Address,
block_number: BlockNumber,
) -> Result<bool, BlockchainError>
pub async fn ots_has_code( &self, address: Address, block_number: BlockNumber, ) -> Result<bool, BlockchainError>
Check if an ETH address contains code at a certain block number.
Sourcepub async fn ots_trace_transaction(
&self,
hash: B256,
) -> Result<Vec<TraceEntry>, BlockchainError>
pub async fn ots_trace_transaction( &self, hash: B256, ) -> Result<Vec<TraceEntry>, BlockchainError>
Trace a transaction and generate a trace call tree.
Sourcepub async fn ots_get_transaction_error(
&self,
hash: B256,
) -> Result<Bytes, BlockchainError>
pub async fn ots_get_transaction_error( &self, hash: B256, ) -> Result<Bytes, BlockchainError>
Given a transaction hash, returns its raw revert reason.
Sourcepub async fn ots_get_block_details(
&self,
number: BlockNumber,
) -> Result<BlockDetails<AnyRpcHeader>, BlockchainError>
pub async fn ots_get_block_details( &self, number: BlockNumber, ) -> Result<BlockDetails<AnyRpcHeader>, BlockchainError>
For simplicity purposes, we return the entire block instead of emptying the values that Otterscan doesn’t want. This is the original purpose of the endpoint (to save bandwidth), but it doesn’t seem necessary in the context of an anvil node
Sourcepub async fn ots_get_block_details_by_hash(
&self,
hash: B256,
) -> Result<BlockDetails<AnyRpcHeader>, BlockchainError>
pub async fn ots_get_block_details_by_hash( &self, hash: B256, ) -> Result<BlockDetails<AnyRpcHeader>, BlockchainError>
For simplicity purposes, we return the entire block instead of emptying the values that Otterscan doesn’t want. This is the original purpose of the endpoint (to save bandwidth), but it doesn’t seem necessary in the context of an anvil node
Sourcepub async fn ots_get_block_transactions(
&self,
number: u64,
page: usize,
page_size: usize,
) -> Result<OtsBlockTransactions<AnyRpcTransaction, AnyRpcHeader>, BlockchainError>
pub async fn ots_get_block_transactions( &self, number: u64, page: usize, page_size: usize, ) -> Result<OtsBlockTransactions<AnyRpcTransaction, AnyRpcHeader>, BlockchainError>
Gets paginated transaction data for a certain block. Return data is similar to eth_getBlockBy* + eth_getTransactionReceipt.
Sourcepub async fn ots_search_transactions_before(
&self,
address: Address,
block_number: u64,
page_size: usize,
) -> Result<TransactionsWithReceipts<Transaction<AnyTxEnvelope>>, BlockchainError>
pub async fn ots_search_transactions_before( &self, address: Address, block_number: u64, page_size: usize, ) -> Result<TransactionsWithReceipts<Transaction<AnyTxEnvelope>>, BlockchainError>
Address history navigation. searches backwards from certain point in time.
Sourcepub async fn ots_search_transactions_after(
&self,
address: Address,
block_number: u64,
page_size: usize,
) -> Result<TransactionsWithReceipts<Transaction<AnyTxEnvelope>>, BlockchainError>
pub async fn ots_search_transactions_after( &self, address: Address, block_number: u64, page_size: usize, ) -> Result<TransactionsWithReceipts<Transaction<AnyTxEnvelope>>, BlockchainError>
Address history navigation. searches forward from certain point in time.
Sourcepub async fn ots_get_transaction_by_sender_and_nonce(
&self,
address: Address,
nonce: U256,
) -> Result<Option<B256>, BlockchainError>
pub async fn ots_get_transaction_by_sender_and_nonce( &self, address: Address, nonce: U256, ) -> Result<Option<B256>, BlockchainError>
Given a sender address and a nonce, returns the tx hash or null if not found. It returns only the tx hash on success, you can use the standard eth_getTransactionByHash after that to get the full transaction data.
Sourcepub async fn ots_get_contract_creator(
&self,
addr: Address,
) -> Result<Option<ContractCreator>, BlockchainError>
pub async fn ots_get_contract_creator( &self, addr: Address, ) -> Result<Option<ContractCreator>, BlockchainError>
Given an ETH contract address, returns the tx hash and the direct address who created the contract.
Sourcepub async fn build_ots_block_details(
&self,
block: AnyRpcBlock,
) -> Result<BlockDetails<Header<AnyHeader>>, BlockchainError>
pub async fn build_ots_block_details( &self, block: AnyRpcBlock, ) -> Result<BlockDetails<Header<AnyHeader>>, BlockchainError>
The response for ots_getBlockDetails includes an issuance
object that requires computing
the total gas spent in a given block.
The only way to do this with the existing API is to explicitly fetch all receipts, to get
their gas_used
. This would be extremely inefficient in a real blockchain RPC, but we can
get away with that in this context.
The original spec
also mentions we can hardcode transactions
and logsBloom
to an empty array to save
bandwidth, because fields weren’t intended to be used in the Otterscan UI at this point.
This has two problems though:
- It makes the endpoint too specific to Otterscan’s implementation
- It breaks the abstraction built in
OtsBlock<TX>
which computestransaction_count
based on the existing list.
Therefore we keep it simple by keeping the data in the response
Sourcepub async fn build_ots_block_tx(
&self,
block: AnyRpcBlock,
page: usize,
page_size: usize,
) -> Result<OtsBlockTransactions<AnyRpcTransaction, AnyRpcHeader>, BlockchainError>
pub async fn build_ots_block_tx( &self, block: AnyRpcBlock, page: usize, page_size: usize, ) -> Result<OtsBlockTransactions<AnyRpcTransaction, AnyRpcHeader>, BlockchainError>
Fetches all receipts for the blocks’s transactions, as required by the
ots_getBlockTransactions
endpoint spec, and returns the final response object.
pub async fn build_ots_search_transactions( &self, hashes: Vec<B256>, first_page: bool, last_page: bool, ) -> Result<TransactionsWithReceipts<Transaction<AnyTxEnvelope>>, BlockchainError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EthApi
impl !RefUnwindSafe for EthApi
impl Send for EthApi
impl Sync for EthApi
impl Unpin for EthApi
impl !UnwindSafe for EthApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 136 bytes