Rust SDK API Reference / Non-blocking APIs / Primary domains / get_primary_domain
Function: get_primary_domain()
pub async fn get_primary_domain(
rpc_client: &RpcClient,
owner: &Pubkey,
) -> Result<Option<Pubkey>, SnsError>
Defined in: rust-crates/sns-sdk/src/non_blocking/primary_domain.rs:10
Derives the primary-domain state account for owner and reads it through RPC. A present state account must be owned by NAME_OFFERS_PROGRAM_ID and parse as PrimaryDomain.
Parameters
| Parameter | Type | Description |
|---|---|---|
rpc_client | &RpcClient | Non-blocking Solana RPC client. |
owner | &Pubkey | Wallet whose selected primary domain is queried. |
Returns
Result<Option<Pubkey>, SnsError>. Some is the selected primary name-account key; None means no primary-domain state account exists. Reverse-resolve the key for a TLD-less display name.
Errors
SnsError::InvalidNameAccountDatawhen a present state account has the wrong owner.SnsError::BorshErrorwhen its primary-domain state is malformed.SnsError::SolanaClientwhen the RPC request fails.
Example
use sns_sdk::non_blocking::primary_domain::get_primary_domain;
if let Some(name_account) = get_primary_domain(&client, &owner).await? {
println!("primary account: {name_account}");
}