Expand description
Aptos Names Service (ANS) client.
Resolves .apt names to addresses and back, and builds the entry-function
payloads needed to register names and manage their primary-name / target
address records. This mirrors the read/write surface of the TypeScript
SDK’s ans namespace, talking to the on-chain router module via view
functions and entry functions.
§Networks
ANS is only deployed on mainnet, testnet, and (for development) localnet.
On those networks AnsClient::new picks the correct router contract
address automatically. For devnet, custom networks, or a privately deployed
ANS, construct the client with AnsClient::with_router_address and supply
the contract address yourself.
§Name format
Names follow the ANS validation rules (see AnsName): each segment must
be 3-63 characters of lowercase a-z, 0-9, and hyphens, and may not start
or end with a hyphen. A name may have at most two segments,
subdomain.domain, and an optional trailing .apt which is stripped.
§Example
use aptos_sdk::api::{AnsClient, FullnodeClient};
use aptos_sdk::config::AptosConfig;
let fullnode = FullnodeClient::new(AptosConfig::mainnet())?;
let ans = AnsClient::new(fullnode);
if let Some(address) = ans.get_target_address("greg.apt").await? {
println!("greg.apt resolves to {address}");
}