Skip to main content

Rust SDK API Reference / Reverse lookup / resolve_reverse_with_parent

Function: resolve_reverse_with_parent()

pub fn resolve_reverse_with_parent(
rpc_client: &RpcClient,
key: &Pubkey,
parent: Option<&Pubkey>,
) -> Result<Option<String>, SnsError>

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

Derives and reads a reverse record for either a top-level name or a subdomain. For subdomains, the implementation removes the SNS reverse-record marker before returning the TLD-less label.

Availability

Requires the blocking feature.

Parameters

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used to read the reverse record.
key&PubkeySNS name-account key to reverse-resolve.
parentOption<&Pubkey>None for a top-level domain; Some(parent) for a subdomain.

Returns

Result<Option<String>, SnsError>. Some contains a TLD-less name or subdomain label; None means the derived reverse account does not exist.

Errors

  • SnsError::InvalidNameAccountData when the reverse account is malformed or has the wrong owner.
  • SnsError::InvalidReverse when the reverse payload is malformed or not UTF-8.
  • SnsError::SolanaClient for RPC failures.

Example

use sns_sdk::{blocking::resolve::resolve_reverse_with_parent, derivation::get_sns_domain_key};
use solana_client::rpc_client::RpcClient;

let client = RpcClient::new("https://your-rpc-endpoint.example".to_string());
let child = get_sns_domain_key("team.example")?;
let label = resolve_reverse_with_parent(&client, &child.key, Some(&child.parent))?;
println!("{label:?}");