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
| Parameter | Type | Description |
|---|---|---|
rpc_client | &RpcClient | Non-blocking Solana RPC client used for registry, record, token, and PDA-owner lookups. |
domain | &str | Full supported .sns or .sol domain name. |
allow_pda | AllowPda | Policy 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:
| Value | Behavior |
|---|---|
AllowPda::Deny | Reject every final PDA target. |
AllowPda::Allow(program_ids) | Allow a PDA only when its runtime account owner is in program_ids. |
AllowPda::AllowAny | Return 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::UnsupportedTldwhen the name is bare, has an unsupported suffix, or uses.solafter the endpoint has reached the cutoff.SnsError::DomainDoesNotExistwhen the SNS domain account does not exist.SnsError::PdaOwnerNotAllowedwhen a final PDA target is rejected byallow_pda.SnsError::CouldNotFindNftOwnerwhen an active tokenized domain has no resolvable NFT owner.SnsError::InvalidRecordData,SnsError::RecordMalformed,SnsError::WrongValidation, orSnsError::InvalidRoawhen a candidateSOLrecord cannot be used.SnsError::SolanaClientwhen 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}");