Skip to main content

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

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used for account and token-owner lookups.
domain&strFull supported .sns or .sol domain.
allow_pdaAllowPdaDeny 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::UnsupportedTld when the suffix is unsupported or a .sol read is past the cutoff.
  • SnsError::DomainDoesNotExist when the resolved name account is absent.
  • SnsError::PdaOwnerNotAllowed when the final PDA violates allow_pda.
  • SnsError::CouldNotFindNftOwner when an active tokenized domain has no resolvable owner.
  • SnsError::SolanaClient for 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}");