Expand description
eth-icons is an icon fetching library for EVM icons.
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.
use eth_icons::{IconClient, IconQuery};
#[tokio::main]
pub async fn main() {
// Create a client
let client = reqwest::Client::new();
// Create an icon client
let icons = IconClient::builder()
.with_reqwest(client)
.with_defaults()
.build();
let weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string();
let weth_icons = icons.resolve(IconQuery::ERC20(1u64, weth)).await;
}§Selecting Sources
Every source is opt-in by default.
use eth_icons::{Address, IconClient, IconQuery, modules::{Blockscout, 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 = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".to_string();
let results = icons.resolve(IconQuery::ERC20(1, weth)).await;
for source in &results {
println!("{}: {:?}", source.source, source.result);
}
}§Available Sources
- Avara - supports ERC20s
- Blockscout - supports ERC20s
- SafeWallet - supports network and native token icons
- Smoldapp - supports network, native tokens, and ERC20s
- Zerion - supports ERC20s
Re-exports§
pub use client::IconClient;pub use client::builder::IconClientBuilder;pub use error::Error;pub use fetcher::IconFetcher;pub use icon::Icon;pub use identity::Address;pub use identity::NetworkId;pub use result::IconResult;pub use result::SourceResult;pub use source::IconQuery;pub use source::IconSource;