Skip to main content

Rust SDK API Reference / Record V2 reads / get_record_v2

Function: get_record_v2()

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

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

Validates the full domain's supported TLD, derives its V2 record address, and reads it through RPC. The returned payload excludes the NameRecordHeader; decode the payload and verify the resulting fields before relying on record content.

Parameters

ParameterTypeDescription
rpc_client&RpcClientNon-blocking Solana RPC client.
domain&strFull supported .sns or .sol domain name.
recordRecordV2 record type to retrieve, such as Record::Url.

Returns

Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>. Some contains the account header and payload; None means the record account does not exist.

Errors

  • SnsError::UnsupportedTld when domain is bare or has an unsupported suffix.
  • SnsError::InvalidNameAccountData when a present record account is invalid.
  • SnsError::SolanaClient when a TLD or record RPC request fails.

Example

use sns_sdk::{non_blocking::record_v2::get_record_v2, record::Record};

if let Some((_header, payload)) = get_record_v2(&client, "bonfida.sns", Record::Url).await? {
println!("record bytes: {}", payload.len());
}