Skip to main content

Rust SDK API Reference / Wallet domains / get_sns_domains_for_owner

Function: get_sns_domains_for_owner()

pub fn get_sns_domains_for_owner(
rpc_client: &RpcClient,
owner: Pubkey,
) -> Result<Vec<Pubkey>, SnsError>

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

Queries the SPL Name Service for top-level SNS name accounts directly owned by a wallet. Tokenized domains and subdomains are excluded.

Availability

Requires the blocking feature.

Parameters

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used for the program-account query.
ownerPubkeyWallet whose directly owned top-level name accounts are requested.

Returns

Result<Vec<Pubkey>, SnsError> containing matching name-account keys. Reverse-resolve a key to obtain its TLD-less display name.

Errors

Returns SnsError::SolanaClient when the program-account RPC request fails.

Example

use sns_sdk::blocking::domain::get_sns_domains_for_owner;
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;

let client = RpcClient::new("https://your-rpc-endpoint.example".to_string());
let owner: Pubkey = std::env::var("OWNER")?.parse()?;
let domains = get_sns_domains_for_owner(&client, owner)?;
println!("{} domains", domains.len());