omer
omer

Reputation: 115

get holder of solana nft using python

I want to get the current holder (and also all past holders list) of a specific Solana NFT, using python.

Currently, I'm using get_confirmed_signature_for_address2 to get the token signatures, then I get the transaction of the newest signature, and then I extract the owner using: transaction["result"]["meta"]["postTokenBalances"][0]["owner"]

But it seems like a really long way to get the holder and I wonder if there is a better way to get it.

Upvotes: 1

Views: 3216

Answers (1)

omer
omer

Reputation: 115

I found the solution at: https://solanacookbook.com/references/nfts.html#get-the-owner-of-an-nft

First, need to get the largest token account, it can retrieve using getTokenLargestAccounts.

Then need to take it and parse it using getParsedAccountInfo, it'll give the owner address from the associate address.

The code is in TS, but the same logic goes in python.

Upvotes: 3

Related Questions