Skip to main content

Rust SDK API Reference / Name registries / resolve_name_registry

Function: resolve_name_registry()

pub fn resolve_name_registry(
rpc_client: &RpcClient,
key: &Pubkey,
) -> Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>

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

Fetches one SPL Name Service account and splits its validated NameRecordHeader from the remaining payload bytes.

Availability

Requires the blocking feature.

Parameters

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used to fetch the account.
key&PubkeyName-registry account public key.

Returns

Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>. Some contains the header and payload without header bytes; None means the account is absent.

Errors

  • SnsError::InvalidNameAccountData when a present account has the wrong owner or insufficient header data.
  • SnsError::BorshError when the header cannot be unpacked.
  • SnsError::SolanaClient for RPC failures.

Example

use sns_sdk::{blocking::resolve::resolve_name_registry, 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((header, payload)) = resolve_name_registry(&client, &key)? {
println!("{} bytes owned by {}", payload.len(), header.owner);
}