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
| Parameter | Type | Description |
|---|---|---|
rpc_client | &RpcClient | Non-blocking Solana RPC client. |
domain | &str | Full supported .sns or .sol domain name. |
record | Record | V2 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::UnsupportedTldwhendomainis bare or has an unsupported suffix.SnsError::InvalidNameAccountDatawhen a present record account is invalid.SnsError::SolanaClientwhen 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());
}