Ready to dive into the world of cross-chain data access? Look no further! This Rust library provides an Ethers middleware to extend ENS (Ethereum Name Service) functionality with CCIP-Read (Cross-Chain Interoperability Protocol - Secure offchain data retrieval) support. Easily interact with ENS names that support the CCIP-Read protocol and make your decentralized applications more fun and powerful!
To install the ethers-ccip-read
middleware, add it to your Cargo.toml
file:
ethers-ccip-read = { git = "https://github.com/ensdomains/ethers-ccip-read" }
Hook up the middleware to your Ethers provider and start your cross-chain adventure! Here's a simple example to get you going;
use anyhow::Result;
use ethers_ccip_read::*;
use std::convert::TryFrom;
#[tokio::main]
async fn main() -> Result<()> {
// Connect to the network
let provider = Provider::<Http>::try_from("https://your.web3.provider")?;
// Enable the middleware
let provider = CCIPReadMiddleware::new(
provider,
);
// Now you can query CCIP-Read supported ENS names.
let ens_name = "1.offchainexample.eth";
let resolver_address = provider.get_resolver(ens_name).await.unwrap();
println!("resolver_address: {:?}", resolver_address);
let supports_wildcard = provider.supports_wildcard(resolver_address).await.unwrap();
println!("supports_wildcard: {:?}", supports_wildcard);
let resolved_address = provider.resolve_name(ens_name).await.unwrap();
println!("resolved_address: {:?}", resolved_address);
Ok(())
}
For more examples, check out the examples directory.