pub struct Client { /* private fields */ }
Expand description

The Etherscan.io API client.

Implementations

Returns the Ether balance of a given address.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let balance = client
        .get_ether_balance_single(&"0x58eB28A67731c570Ef827C365c89B5751F9E6b0a".parse().unwrap(),
        None).await.unwrap();

Returns the balance of the accounts from a list of addresses.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let balances = client
        .get_ether_balance_multi(&vec![&"0x58eB28A67731c570Ef827C365c89B5751F9E6b0a".parse().unwrap()],
        None).await.unwrap();

Returns the list of transactions performed by an address, with optional pagination.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let txs = client
        .get_transactions(&"0x58eB28A67731c570Ef827C365c89B5751F9E6b0a".parse().unwrap(),
        None).await.unwrap();

Returns the list of internal transactions performed by an address or within a transaction, with optional pagination.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let txs = client
        .get_internal_transactions(
            InternalTxQueryOption::ByAddress(
                "0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3".parse().unwrap()), None).await.unwrap();

Returns the list of ERC-20 tokens transferred by an address, with optional filtering by token contract.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let txs = client
        .get_erc20_token_transfer_events(
            TokenQueryOption::ByAddress(
                "0x4e83362442b8d1bec281594cea3050c8eb01311c".parse().unwrap()), None).await.unwrap();

Returns the list of ERC-721 ( NFT ) tokens transferred by an address, with optional filtering by token contract.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let txs = client
        .get_erc721_token_transfer_events(
            TokenQueryOption::ByAddressAndContract(
                "0x6975be450864c02b4613023c2152ee0743572325".parse().unwrap(),
                "0x06012c8cf97bead5deae237070f9587f8e7a266d".parse().unwrap(),
         ), None).await.unwrap();

Returns the list of blocks mined by an address.


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let blocks = client
        .get_mined_blocks(&"0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b".parse().unwrap(), None, None)
        .await.unwrap();

Submit Source Code for Verification

Check Source Code Verification Status with receipt received from [Self::submit_contract_verification]

Returns the contract ABI of a verified contract


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let abi = client
        .contract_abi("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".parse().unwrap())
        .await.unwrap();

Get Contract Source Code for Verified Contract Source Codes


    let client = Client::new(Chain::Mainnet, "API_KEY").unwrap();
    let meta = client
        .contract_source_code("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413".parse().unwrap())
        .await.unwrap();
    let code = meta.source_code();

Returns the estimated time, in seconds, for a transaction to be confirmed on the blockchain for the specified gas price

Returns the current Safe, Proposed and Fast gas prices Post EIP-1559 changes:

  • Safe/Proposed/Fast gas price recommendations are now modeled as Priority Fees.
  • New field suggestBaseFee, the baseFee of the next pending block
  • New field gasUsedRatio, to estimate how busy the network is

Returns the status of a contract execution

Returns the status of a transaction execution: false for failed and true for successful

Creates a ClientBuilder to configure a Client. This is the same as ClientBuilder::default().

Example
use ethers_core::types::Chain;
use ethers_etherscan::Client;
let client = Client::builder().with_api_key("<API KEY>").chain(Chain::Mainnet).unwrap().build().unwrap();

Creates a new instance that caches etherscan requests

Create a new client with the correct endpoints based on the chain and provided API key

Create a new client with the correct endpoints based on the chain and API key from ETHERSCAN_API_KEY environment variable

Return the URL for the given block number

Return the URL for the given address

Return the URL for the given transaction hash

Return the URL for the given token hash

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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