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
| Parameter | Type | Description |
|---|---|---|
rpc_client | &solana_client::rpc_client::RpcClient | Blocking Solana RPC client used for SRS and SNS resolution. |
domain | &str | Full supported .sns or .sol domain name. |
allow_pda | AllowPda | Policy 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::SnsSolResolutionMismatchwhen 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}");