eth-icons 0.0.2

Retrieve ethereum icons
Documentation

[!IMPORTANT] eth-icons uses third party services to fetch iconography, not ethereum rpc calls.

Network (Mainnet, Sepolia, etc.), Native Asset (ETH, sepETH, etc.), and ERC20 (wETH, etc.) icons are an inherit non-standardized extension of the ethereum protocol. To allow for easily integrating these into your application eth-icons aims to bring a set of helpers to obtain iconography from various sources.

Quickstart

cargo add eth-icons
use eth_icons::{IconClient, IconQuery};

// Create a client
let client = reqwest::client();

// Create an icon client
let icons = IconClient::builder()
  .with_reqwest(client)
  .with_defaults();

let weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
let weth_icons = icons.resolve(IconQuery::ERC20(1.into(), weth.into())).await;

Data Sources

Currently supported data sources include:

Selecting Sources

Every source is opt-in by default.

use eth_icons::{Address, Blockscout, IconClient, IconQuery, Zerion};

#[tokio::main]
pub async fn main() {
    let icons = IconClient::builder()
        .with_reqwest(reqwest::Client::new())
        .with_source(Blockscout)
        .with_source(Zerion)
        .build();
    let weth = Address("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string());

    let results = icons.resolve(IconQuery::ERC20(1, weth)).await;

    for result in &results {
        println!("{}: {:?}", result.source, result.result);
    }
}

Documentation

You can read the documentation at docs.rs/eth-icons.