forked from ensdomains/ethers-ccip-read
-
Notifications
You must be signed in to change notification settings - Fork 0
/
offchain.rs
39 lines (34 loc) · 1.24 KB
/
offchain.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use alloy::providers::ProviderBuilder;
use alloy_ccip_read::CCIPReader;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let rpc = alloy_ccip_read::consts::DEFAULT_ETHEREUM_RPC_URL;
let provider = ProviderBuilder::new().on_http(rpc.parse().unwrap());
let reader = CCIPReader::new(provider.boxed());
let registry_address = None;
for ens_name in [
"1.offchainexample.eth",
"levvv.xyz",
"itslev.cb.id",
"llev.me",
] {
println!("\nresolving name: {}", ens_name);
let resolver_address =
alloy_ccip_read::ens::get_resolver_wildcarded(&reader, registry_address, ens_name)
.await
.unwrap();
println!("resolver_address: {:?}", resolver_address);
let supports_wildcard = alloy_ccip_read::ens::supports_wildcard(&reader, resolver_address)
.await
.unwrap();
println!("supports_wildcard: {:?}", supports_wildcard);
let resolved_address =
alloy_ccip_read::ens::resolve_name(&reader, registry_address, ens_name)
.await
.unwrap();
println!("resolved_address: {:?}", resolved_address);
}
Ok(())
}