alloy-ens-extender
A extension of alloy-ens. Adds more functionalities to the library.
Usage
Installation
cargo add alloy-ens-extender
Avatar Resolution
fn main(){
let provider = ProviderBuilder::new()
.connect_http("http://reth-ethereum.ithaca.xyz/rpc".parse().unwrap());
let name = "nick.eth";
let res = provider.lookup_avatar(name, None).await.unwrap();
}
Output:
https://api.opensea.io/api/v1/metadata/0x495f947276749Ce646f68AC8c248420045cb7b5e/8112316025873927737505937898915153732580103913704334048512380490797008551937
Avatar Resolution with gateway
fn main(){
let provider = ProviderBuilder::new()
.connect_http("http://reth-ethereum.ithaca.xyz/rpc".parse().unwrap());
let gateway : HashMap<String,String> = HashMap::new();
gateway.insert(
"ipfs".to_string(),
"https://gateway.pinata.cloud/ipfs/".to_string()
);
let name = "nick.eth";
let res = provider.lookup_avatar(name,gateway)).await.unwrap();
}
Output:
https://gateway.pinata.cloud/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/0x495f947276749Ce646f68AC8c248420045cb7b5e/8112316025873927737505937898915153732580103913704334048512380490797008551937
Normalization
use alloy_ens_extender::normalize;
fn main(){
let name = "‐Ξ1️⃣";
let normalized_name = normalize(name);
println!("Normalized name: {}", normalized_name);
}
Output:
Normalized name: -ξ1⃣