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
| Parameter | Type | Description |
|---|---|---|
rpc_client | &solana_client::rpc_client::RpcClient | Blocking client used to fetch the record account. |
domain | &str | Full supported .sns or .sol domain. |
record | Record | SNS 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::UnsupportedTldfor a bare, unsupported, or unavailable.soldomain.SnsError::InvalidNameAccountDatawhen a present record account is malformed or has the wrong owner.SnsError::SolanaClientfor 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);
}