Rust SDK API Reference / Domain resolution / resolve
Function: resolve()
pub fn resolve(
rpc_client: &RpcClient,
domain: &str,
allow_pda: AllowPda,
) -> Result<Pubkey, SnsError>
Defined in: rust-crates/sns-sdk/src/blocking/resolve.rs:36
Resolves a full .sns or currently supported .sol name to its effective owner. SNS resolution prefers an active tokenized-domain owner, then a valid V2 SOL record, then a valid V1 SOL record, and finally the name-registry owner. SRS-backed .sol resolution is disabled; legacy SNS-backed .sol reads stop at finalized slot 452,825,395.
For .sol resolution that must require matching SRS and SNS targets when SRS-backed resolution is enabled, use safe_resolve.
Availability
Requires the blocking feature, which exposes sns_sdk::blocking instead of sns_sdk::non_blocking.
Parameters
| Parameter | Type | Description |
|---|---|---|
rpc_client | &solana_client::rpc_client::RpcClient | Blocking client used for account and token-owner lookups. |
domain | &str | Full supported .sns or .sol domain. |
allow_pda | AllowPda | Deny rejects PDAs; Allow(program_ids) accepts only PDAs owned by an allowed program; AllowAny accepts any PDA. |
Returns
Result<Pubkey, SnsError> containing the effective target public key after ownership precedence and PDA policy are applied.
Errors
SnsError::UnsupportedTldwhen the suffix is unsupported or a.solread is past the cutoff.SnsError::DomainDoesNotExistwhen the resolved name account is absent.SnsError::PdaOwnerNotAllowedwhen the final PDA violatesallow_pda.SnsError::CouldNotFindNftOwnerwhen an active tokenized domain has no resolvable owner.SnsError::SolanaClientfor RPC failures.
Example
use sns_sdk::blocking::resolve::{resolve, AllowPda};
use solana_client::rpc_client::RpcClient;
let client = RpcClient::new("https://your-rpc-endpoint.example".to_string());
let target = resolve(&client, "example.sns", AllowPda::Deny)?;
println!("{target}");