简体   繁体   English

使用 python 获得 solana nft 的持有者

[英]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.我想使用 python 获取特定 Solana NFT 的当前持有者(以及所有过去的持有者列表)。

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"]目前,我正在使用 get_confirmed_signature_for_address2 获取令牌签名,然后获取最新签名的交易,然后使用以下方法提取所有者:transaction["result"]["meta"]["postTokenBalances"][0] [“所有者”]

But it seems like a really long way to get the holder and I wonder if there is a better way to get it.但是获得持有人似乎还有很长的路要走,我想知道是否有更好的方法来获得它。

I found the solution at: https://solanacookbook.com/references/nfts.html#get-the-owner-of-an-nft我在以下位置找到了解决方案: 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.首先,需要获取最大的token账户,可以使用getTokenLargestAccounts获取。

Then need to take it and parse it using getParsedAccountInfo, it'll give the owner address from the associate address.然后需要获取它并使用 getParsedAccountInfo 对其进行解析,它将从关联地址中给出所有者地址。

The code is in TS, but the same logic goes in python.代码在 TS 中,但在 python 中也是同样的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM