Skip to main content

Rust SDK API Reference / Domain resolution / safe_resolve

Function: safe_resolve()

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

Defined in: rust-crates/sns-sdk/src/blocking/resolve.rs:55

Uses the same routing as resolve. When SRS-backed .sol resolution is enabled, it resolves the TLD-trimmed name through both SRS and SNS with the same allow_pda policy. Matching targets are returned; differing targets produce SnsError::SnsSolResolutionMismatch.

For .sns, unsupported inputs, and .sol while SRS-backed resolution is disabled, this function follows ordinary resolve behavior. Resolver and RPC errors propagate unchanged.

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 Solana RPC client used for SRS and SNS resolution.
domain&strFull supported .sns or .sol domain name.
allow_pdaAllowPdaPolicy applied consistently to both SRS and SNS final-owner resolution.

Returns

Result<Pubkey, SnsError> containing the matching SRS/SNS target when compared, or the target returned by ordinary resolution.

Errors

  • SnsError::SnsSolResolutionMismatch when enabled SRS and SNS resolution return different targets.
  • Any error returned by ordinary SRS or SNS resolution, including RPC, domain, record, and PDA-policy errors.

Example

use sns_sdk::blocking::resolve::{safe_resolve, AllowPda};
use solana_client::rpc_client::RpcClient;

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