Skip to main content

Rust SDK API Reference / Record V1 / get_record

Function: get_record()

pub fn get_record(
rpc_client: &RpcClient,
domain: &str,
record: Record,
) -> Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>

Defined in: rust-crates/sns-sdk/src/blocking/record_v1.rs:11

Derives the legacy record address for a supported full domain and fetches its name-registry account through the blocking client.

Availability

Requires the blocking feature.

Parameters

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used to fetch the record account.
domain&strFull supported .sns or .sol domain.
recordRecordLegacy SNS record kind to fetch.

Returns

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

Errors

  • SnsError::UnsupportedTld for a bare, unsupported, or unavailable .sol domain.
  • SnsError::InvalidNameAccountData when an existing record account is malformed or has the wrong owner.
  • SnsError::SolanaClient for RPC failures.

Example

use sns_sdk::{blocking::record_v1::get_record, record::Record};
use solana_client::rpc_client::RpcClient;

let client = RpcClient::new("https://your-rpc-endpoint.example".to_string());
if let Some((header, payload)) = get_record(&client, "example.sns", Record::Url)? {
println!("{} bytes owned by {}", payload.len(), header.owner);
}