Struct ethers_rs::Provider

source ·
pub struct Provider { /* private fields */ }
Expand description

Ether network api provider

Implementations§

source§

impl Provider

source

pub async fn eth_block_number(
    &mut self
) -> impl Future<Output = Result<U256, Error<String, Value>>>

Returns the number of most recent block.

source

pub async fn eth_chain_id(
    &mut self
) -> impl Future<Output = Result<U64, Error<String, Value>>>

Returns the chain ID of the current network

source

pub async fn eth_get_block_by_hash<B>(
    &mut self,
    block_hash: B,
    hydrated: bool
) -> impl Future<Output = Result<Option<Block>, Error<String, Value>>>where
    B: TryInto<H256>,
    <B as TryInto<H256>>::Error: Debug + Display,

Returns information about a block by hash.

source

pub async fn eth_get_block_by_number<BT>(
    &mut self,
    block_number_or_tag: BT,
    hydrated: bool
) -> impl Future<Output = Result<Option<Block>, Error<String, Value>>>where
    BT: TryInto<BlockNumberOrTag>,
    <BT as TryInto<BlockNumberOrTag>>::Error: Debug + Display,

Returns information about a block by number

source

pub async fn eth_get_block_transaction_count_by_hash<H>(
    &mut self,
    hash: H
) -> impl Future<Output = Result<U64, Error<String, Value>>>where
    H: TryInto<H256>,
    <H as TryInto<H256>>::Error: Debug + Display,

Returns the number of transactions in a block from a block matching the given block hash

source

pub async fn eth_get_uncle_count_by_block_hash<H>(
    &mut self,
    hash: H
) -> impl Future<Output = Result<U64, Error<String, Value>>>where
    H: TryInto<H256>,
    <H as TryInto<H256>>::Error: Debug + Display,

Returns the number of uncles in a block from a block matching the given block hash

source

pub async fn eth_get_uncle_count_by_block_number<BT>(
    &mut self,
    block_number_or_tag: BT
) -> impl Future<Output = Result<U64, Error<String, Value>>>where
    BT: TryInto<BlockNumberOrTag>,
    <BT as TryInto<BlockNumberOrTag>>::Error: Debug + Display,

Returns the number of uncles in a block from a block matching the given block hash

source

pub async fn eth_syncing(
    &mut self
) -> impl Future<Output = Result<SyncingStatus, Error<String, Value>>>

Returns an object with data about the sync status or false

source

pub async fn eth_coinbase(
    &mut self
) -> impl Future<Output = Result<H160, Error<String, Value>>>

Returns the client coinbase address.

source

pub async fn eth_accounts(
    &mut self
) -> impl Future<Output = Result<Vec<H160, Global>, Error<String, Value>>>

Returns a list of addresses owned by client.

source

pub async fn eth_call<TX, BT>(
    &mut self,
    transaction: TX,
    block_number_or_tag: Option<BT>
) -> impl Future<Output = Result<Bytecode, Error<String, Value>>>where
    TX: TryInto<TypedTransactionRequest>,
    <TX as TryInto<TypedTransactionRequest>>::Error: Debug + Display,
    BT: TryInto<BlockNumberOrTag>,
    <BT as TryInto<BlockNumberOrTag>>::Error: Debug + Display,

Executes a new message call immediately without creating a transaction on the block chain.

source

pub async fn eth_estimate_gas<TX, BT>(
    &mut self,
    transaction: TX,
    block_number_or_tag: Option<BT>
) -> impl Future<Output = Result<U256, Error<String, Value>>>where
    TX: TryInto<TypedTransactionRequest>,
    <TX as TryInto<TypedTransactionRequest>>::Error: Debug + Display,
    BT: TryInto<BlockNumberOrTag>,
    <BT as TryInto<BlockNumberOrTag>>::Error: Debug + Display,

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.

source

pub async fn eth_create_accesslist<TX, BT>(
    &mut self,
    transaction: TX,
    block_number_or_tag: Option<BT>
) -> impl Future<Output = Result<U256, Error<String, Value>>>where
    TX: TryInto<Transaction>,
    <TX as TryInto<Transaction>>::Error: Debug + Display,
    BT: TryInto<BlockNumberOrTag>,
    <BT as TryInto<BlockNumberOrTag>>::Error: Debug + Display,

Generates an access list for a transaction

source

pub async fn eth_gas_price(
    &mut self
) -> impl Future<Output = Result<U256, Error<String, Value>>>

Returns the current price gas in wei.

source

pub async fn eth_max_priority_fee_per_gas(
    &mut self
) -> impl Future<Output = Result<U256, Error<String, Value>>>

Returns the current maxPriorityFeePerGas per gas in wei.

source

pub async fn eth_fee_history<N, BT, RP>(
    &mut self,
    block_count: N,
    newest_block: BT,
    reward_percentiles: RP
) -> impl Future<Output = Result<FeeHistory, Error<String, Value>>>where
    N: TryInto<U256>,
    <N as TryInto<U256>>::Error: Debug + Display,
    BT: TryInto<BlockNumberOrTag>,
    <BT as TryInto<BlockNumberOrTag>>::Error: Debug + Display,
    RP: AsRef<[f64]>,

Returns transaction base fee per gas and effective priority fee per gas for the requested/supported block range.

source

pub async fn eth_new_filter<F>(
    &mut self,
    filter: F
) -> impl Future<Output = Result<U256, Error<String, Value>>>where
    F: TryInto<Filter>,
    <F as TryInto<Filter>>::Error: Debug + Display,

Returns transaction base fee per gas and effective priority fee per gas for the requested/supported block range.

source

pub async fn eth_new_block_filter(
    &mut self
) -> impl Future<Output = Result<U256, Error<String, Value>>>

Creates new filter in the node,to notify when a new block arrives.

source

pub async fn eth_new_pending_transaction_filter(
    &mut self
) -> impl Future<Output = Result<U256, Error<String, Value>>>

Creates new filter in the node,to notify when new pending transactions arrive.

source

pub async fn eth_uninstall_filter<N>(
    &mut self,
    id: N
) -> impl Future<Output = Result<bool, Error<String, Value>>>where
    N: TryInto<U256>,
    <N as TryInto<U256>>::Error: Debug + Display,

Uninstalls a filter with given id

source

pub async fn eth_get_filter_changes<N>(
    &mut self,
    id: N
) -> impl Future<Output = Result<FilterEvents, Error<String, Value>>>where
    N: TryInto<U256>,
    <N as TryInto<U256>>::Error: Debug + Display,

Polling method for a filter, which returns an arrya of logs which occurred since last poll

source

pub async fn eth_get_filter_logs<N>(
    &mut self,
    id: N
) -> impl Future<Output = Result<FilterEvents, Error<String, Value>>>where
    N: TryInto<U256>,
    <N as TryInto<U256>>::Error: Debug + Display,

Returns any arrays of all logs matching filter with given id

source

pub async fn eth_get_logs<F>(
    &mut self,
    filter: F
) -> impl Future<Output = Result<FilterEvents, Error<String, Value>>>where
    F: TryInto<Filter>,
    <F as TryInto<Filter>>::Error: Debug + Display,

Returns an array of all logs matching filter with filter description

source

pub async fn eth_sign<A, M>(
    &mut self,
    address: A,
    message: M
) -> impl Future<Output = Result<H520, Error<String, Value>>>where
    A: TryInto<H160>,
    <A as TryInto<H160>>::Error: Debug + Display,
    M: TryInto<Bytecode>,
    <M as TryInto<Bytecode>>::Error: Debug + Display,

Returns an EIP-191 signature over the provided data

source

pub async fn eth_sign_transaction<T>(
    &mut self,
    transaction: T
) -> impl Future<Output = Result<Bytecode, Error<String, Value>>>where
    T: TryInto<Transaction>,
    <T as TryInto<Transaction>>::Error: Debug + Display,

Returns an RLP encoded transaction signed by the specified account.

source

pub async fn eth_get_balance<A>(
    &mut self,
    address: A
) -> impl Future<Output = Result<U256, Error<String, Value>>>where
    A: TryInto<H160>,
    <A as TryInto<H160>>::Error: Debug + Display,

Returns the balance of the account given address.

source

pub async fn eth_get_transaction_count<A>(
    &mut self,
    address: A
) -> impl Future<Output = Result<U256, Error<String, Value>>>where
    A: TryInto<H160>,
    <A as TryInto<H160>>::Error: Debug + Display,

Returns the number of transactions sent from an address

source

pub async fn eth_send_raw_transaction<B>(
    &mut self,
    raw: B
) -> impl Future<Output = Result<H256, Error<String, Value>>>where
    B: TryInto<Bytecode>,
    <B as TryInto<Bytecode>>::Error: Debug + Display,

Submit a raw transaction.

source

pub async fn eth_get_transaction_by_hash<H>(
    &mut self,
    tx_hash: H
) -> impl Future<Output = Result<Option<Transaction>, Error<String, Value>>>where
    H: TryInto<H256>,
    <H as TryInto<H256>>::Error: Debug + Display,

source

pub async fn eth_get_transaction_receipt<H>(
    &mut self,
    tx_hash: H
) -> impl Future<Output = Result<Option<TransactionReceipt>, Error<String, Value>>>where
    H: TryInto<H256>,
    <H as TryInto<H256>>::Error: Debug + Display,

Returns the receipt of a transaction by transaction hash

source§

impl Provider

source

pub fn register_filter_listener<A, T>(
    &self,
    address: Option<A>,
    topic_filter: Option<T>
) -> Result<FilterReceiver<Timeout>, Error>where
    A: TryInto<AddressFilter>,
    <A as TryInto<AddressFilter>>::Error: Error + Sync + Send + 'static,
    T: TryInto<TopicFilter>,
    <T as TryInto<TopicFilter>>::Error: Error + Sync + Send + 'static,

source

pub fn register_transaction_listener<H>(
    &self,
    tx_hash: H
) -> Result<TransactionReceipter<Timeout>, Error>where
    H: TryInto<H256>,
    <H as TryInto<H256>>::Error: Error + Sync + Send + 'static,

source§

impl Provider

source

pub fn new(id: String, rpc_client: Client) -> Provider

source

pub fn id(&self) -> &str

source

pub fn client(&mut self) -> &mut Client

Get provider inner jsonrpc Client ref.

Trait Implementations§

source§

impl Clone for Provider

source§

fn clone(&self) -> Provider

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<Provider> for Client

source§

fn from(value: Provider) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
    S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more