Skip to main content

Rust SDK API Reference / Reverse lookup / resolve_reverse

Function: resolve_reverse()

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

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

Derives and reads the reverse-record account for a top-level SNS name account. The returned name is TLD-less.

Availability

Requires the blocking feature.

Parameters

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used to read the reverse record.
key&PubkeyTop-level SNS name-account key.

Returns

Result<Option<String>, SnsError>. Some contains the TLD-less reverse name; None means no reverse account exists.

Errors

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

Example

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

let client = RpcClient::new("https://your-rpc-endpoint.example".to_string());
let key = get_sns_domain_key("example")?.key;
if let Some(name) = resolve_reverse(&client, &key)? {
println!("{name}.sns");
}