Skip to main content

Rust SDK API Reference / Record V2 reads / get_record_v2

Function: get_record_v2()

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

Defined in: rust-crates/sns-sdk/src/blocking/record_v2.rs:12

Validates and trims a full supported domain, derives its V2 record address, and reads the corresponding name-registry account.

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.
recordRecordSNS record kind to fetch.

Returns

Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>. Some contains the header and V2 payload without header bytes; None means the record is absent. Decode and verify the payload with record_v2::decode_record_v2_fields as appropriate for the record kind.

Errors

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

Example

use sns_sdk::{blocking::record_v2::get_record_v2, 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_v2(&client, "example.sns", Record::Url)? {
println!("{} bytes owned by {}", payload.len(), header.owner);
}