pub struct Rpc<H> { /* private fields */ }Expand description
One chain’s JSON-RPC: a URL and the wire to it.
Implementations§
Source§impl<H: Http> Rpc<H>
impl<H: Http> Rpc<H>
Sourcepub fn new(http: H, url: impl Into<String>) -> Self
pub fn new(http: H, url: impl Into<String>) -> Self
Any node: an Arbitrum RPC, or HyperEVM through a provider.
Sourcepub async fn run<T>(&self, query: Query<T>) -> Result<T, RpcError>
pub async fn run<T>(&self, query: Query<T>) -> Result<T, RpcError>
Posts the query once and reads the answer. Nothing is retried.
Sourcepub async fn block_number(&self) -> Result<u64, RpcError>
pub async fn block_number(&self) -> Result<u64, RpcError>
Runs eth::block_number: the newest block’s number.
Sourcepub async fn balance(
&self,
owner: Address,
block: BlockTag,
) -> Result<U256, RpcError>
pub async fn balance( &self, owner: Address, block: BlockTag, ) -> Result<U256, RpcError>
Runs eth::balance: wei of the chain’s coin owner holds at block.
Sourcepub async fn transaction_count(
&self,
owner: Address,
block: BlockTag,
) -> Result<u64, RpcError>
pub async fn transaction_count( &self, owner: Address, block: BlockTag, ) -> Result<u64, RpcError>
Runs eth::transaction_count: the next nonce of owner at block.
Sourcepub async fn gas_price(&self) -> Result<U256, RpcError>
pub async fn gas_price(&self) -> Result<U256, RpcError>
Runs eth::gas_price: on HyperEVM, the next small block’s base fee, in wei.
Sourcepub async fn max_priority_fee(&self) -> Result<U256, RpcError>
pub async fn max_priority_fee(&self) -> Result<U256, RpcError>
Runs eth::max_priority_fee: the suggested tip in wei; on HyperEVM, zero for now.
Sourcepub async fn fee_history(
&self,
blocks: u64,
newest: BlockTag,
percentiles: &[u8],
) -> Result<FeeHistory, RpcError>
pub async fn fee_history( &self, blocks: u64, newest: BlockTag, percentiles: &[u8], ) -> Result<FeeHistory, RpcError>
Runs eth::fee_history: base fees and tips over blocks blocks up to newest.
Sourcepub async fn estimate_gas(&self, call: &CallRequest) -> Result<u64, RpcError>
pub async fn estimate_gas(&self, call: &CallRequest) -> Result<u64, RpcError>
Runs eth::estimate_gas: the gas the call or creation would use.
Sourcepub async fn call(
&self,
call: &CallRequest,
block: BlockTag,
) -> Result<Vec<u8>, RpcError>
pub async fn call( &self, call: &CallRequest, block: BlockTag, ) -> Result<Vec<u8>, RpcError>
Runs eth::call: the bytes the call returns at block, without sending a transaction.
Sourcepub async fn send_raw_transaction(&self, raw: &[u8]) -> Result<B256, RpcError>
pub async fn send_raw_transaction(&self, raw: &[u8]) -> Result<B256, RpcError>
Sent once. With no answer the transaction may still have landed: look
for its receipt by crate::client::evm::tx::tx_hash before sending it again.
Sourcepub async fn receipt(&self, hash: B256) -> Result<Option<Receipt>, RpcError>
pub async fn receipt(&self, hash: B256) -> Result<Option<Receipt>, RpcError>
Runs eth::receipt: None until the transaction is mined.
Sourcepub async fn transaction(
&self,
hash: B256,
) -> Result<Option<Transaction>, RpcError>
pub async fn transaction( &self, hash: B256, ) -> Result<Option<Transaction>, RpcError>
Runs eth::transaction: None for a hash the node does not know.
Sourcepub async fn block(
&self,
block: BlockTag,
full: bool,
) -> Result<Option<Block>, RpcError>
pub async fn block( &self, block: BlockTag, full: bool, ) -> Result<Option<Block>, RpcError>
Runs eth::block, with whole transactions when full.
Sourcepub async fn code(
&self,
at: Address,
block: BlockTag,
) -> Result<Vec<u8>, RpcError>
pub async fn code( &self, at: Address, block: BlockTag, ) -> Result<Vec<u8>, RpcError>
Runs eth::code: the code at at, empty for an account that is not a contract.
Sourcepub async fn storage_at(
&self,
at: Address,
slot: U256,
block: BlockTag,
) -> Result<B256, RpcError>
pub async fn storage_at( &self, at: Address, slot: U256, block: BlockTag, ) -> Result<B256, RpcError>
Runs eth::storage_at: the word in storage slot of at.
Sourcepub async fn logs(&self, filter: &LogFilter) -> Result<Vec<Log>, RpcError>
pub async fn logs(&self, filter: &LogFilter) -> Result<Vec<Log>, RpcError>
Runs eth::logs: every log the filter matches.
Sourcepub async fn big_block_gas_price(&self) -> Result<U256, RpcError>
pub async fn big_block_gas_price(&self) -> Result<U256, RpcError>
Runs eth::big_block_gas_price: on HyperEVM, the next big block’s base fee, in wei.
Sourcepub async fn using_big_blocks(&self, owner: Address) -> Result<bool, RpcError>
pub async fn using_big_blocks(&self, owner: Address) -> Result<bool, RpcError>
Runs eth::using_big_blocks: whether owner’s transactions go to HyperEVM’s big blocks.