Skip to main content

Rust SDK API Reference / Non-blocking APIs / Domain resolution / resolve

Function: resolve()

pub async fn resolve(
rpc_client: &RpcClient,
domain: &str,
allow_pda: AllowPda,
) -> Result<Pubkey, SnsError>

Defined in: rust-crates/sns-sdk/src/non_blocking/resolve.rs:36

Resolves a full .sns or currently supported .sol domain to its effective target public key. For .sns, ownership precedence is: an active tokenized-domain owner, a valid V2 SOL record, a valid V1 SOL record, then the name-registry owner.

.sol currently uses legacy SNS-backed resolution until finalized slot 452,825,395; it then pauses automatically for that RPC endpoint. SRS-backed .sol resolution remains disabled until the complete ownership path is available.

For .sol resolution that must require matching SRS and SNS targets when SRS-backed resolution is enabled, use safe_resolve.

Availability

This API is available in the default build. Enabling the blocking feature replaces sns_sdk::non_blocking with sns_sdk::blocking.

Parameters

ParameterTypeDescription
rpc_client&RpcClientNon-blocking Solana RPC client used for registry, record, token, and PDA-owner lookups.
domain&strFull supported .sns or .sol domain name.
allow_pdaAllowPdaPolicy controlling whether the final resolved target may be a PDA.

AllowPda applies only to the final registry or SRS public-key owner, not valid record or tokenized-domain owners:

ValueBehavior
AllowPda::DenyReject every final PDA target.
AllowPda::Allow(program_ids)Allow a PDA only when its runtime account owner is in program_ids.
AllowPda::AllowAnyReturn any final PDA target without checking its runtime account owner.

Use AllowPda::Deny unless the application intentionally supports PDA resolution targets.

Returns

Result<Pubkey, SnsError> containing the effective target after SNS ownership precedence and the applicable PDA policy.

Errors

  • SnsError::UnsupportedTld when the name is bare, has an unsupported suffix, or uses .sol after the endpoint has reached the cutoff.
  • SnsError::DomainDoesNotExist when the SNS domain account does not exist.
  • SnsError::PdaOwnerNotAllowed when a final PDA target is rejected by allow_pda.
  • SnsError::CouldNotFindNftOwner when an active tokenized domain has no resolvable NFT owner.
  • SnsError::InvalidRecordData, SnsError::RecordMalformed, SnsError::WrongValidation, or SnsError::InvalidRoa when a candidate SOL record cannot be used.
  • SnsError::SolanaClient when an RPC request fails.

Example

use sns_sdk::non_blocking::resolve::{resolve, AllowPda};
use solana_client::nonblocking::rpc_client::RpcClient;

let client = RpcClient::new("https://your-rpc-endpoint.example".to_string());
let target = resolve(&client, "example.sns", AllowPda::Deny).await?;
println!("{target}");