Skip to main content

Rust SDK API Reference / Tokenized domains / get_sns_nfts_for_owner

Function: get_sns_nfts_for_owner()

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

Defined in: rust-crates/sns-sdk/src/blocking/nft.rs:76

Finds the wallet's token records, reverse-resolves their SNS name accounts, and returns only records with reverse data. Each SnsNftDomain contains a TLD-less reverse, name-account key, and NFT mint; entries without reverse data are omitted.

Availability

Requires the blocking feature.

Parameters

ParameterTypeDescription
rpc_client&solana_client::rpc_client::RpcClientBlocking client used for token, record, and reverse-record queries.
owner&PubkeyWallet whose tokenized SNS domains are requested.

Returns

Result<Vec<SnsNftDomain>, SnsError> containing domains with reverse data, in the order of the token records that produced them.

Errors

  • SnsError::SolanaClient when a required token, record, or reverse-record query fails.
  • SnsError::InvalidNameAccountData when a fetched reverse account is malformed or has the wrong owner.
  • SnsError::InvalidReverse when a reverse payload is malformed or not UTF-8.

Example

use sns_sdk::blocking::nft::get_sns_nfts_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()?;
for domain in get_sns_nfts_for_owner(&client, &owner)? {
println!("{}.sns", domain.reverse);
}