获取solana nft的所有交易

发布于 2025-02-13 19:51:44 字数 916 浏览 0 评论 0原文

我想收集NFT的所有交易。

例如,您可以在此处显示所有交易:

https://explorer.solana.com/address/2nzt8tyeafgjdftkzkb7rgyshvvyxtr7cpvvpqaz2a4v

或在这里:

https://solscan.io/token/2nzt8tyeafgjdftkzkb7rgyshvvyxtr7cpvvpqaz2a4v#txs

但是有什么方法可以与API一起做到这一点?

我检查了

solana-py: https://michaelhly.githly.githly.githly.io/solana-py/solana-py/

和solscan api: https://public-api.solscan.io/docs/

做到这一点。

I want to collect all transactions for an NFT.

For example, you can display all transactions here:

https://explorer.solana.com/address/2Nzt8TYeAfgJDftKzkb7rgYShVvyXTR7cPVvpqaZ2a4V

or here:

https://solscan.io/token/2Nzt8TYeAfgJDftKzkb7rgYShVvyXTR7cPVvpqaZ2a4V#txs

But is there any way to do this with the API?

I checked

solana-py: https://michaelhly.github.io/solana-py/

and solscan api: https://public-api.solscan.io/docs/

But I could not find a way to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

得不到的就毁灭 2025-02-20 19:51:44

您可以使用 getsignatures foraddressforaddress MINT和WALK的RPC方法向后获取所有交易。

这是JS中的一个示例:

import {
  Connection,
  clusterApiUrl,
  ConfirmedSignatureInfo,
  PublicKey,
} from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));

export const getTxs = async (connection: Connection, pubkey: PublicKey) => {
  const txs: ConfirmedSignatureInfo[] = [];

  // Walk backward
  let lastTransactions = await connection.getConfirmedSignaturesForAddress2(
    pubkey
  );
  let before = lastTransactions[lastTransactions.length - 1].signature;
  txs.push(...lastTransactions);

  while (true) {
    const newTransactions = await connection.getConfirmedSignaturesForAddress2(
      pubkey,
      {
        before,
      }
    );
    if (newTransactions.length === 0) break;
    txs.push(...newTransactions);
    before = newTransactions[newTransactions.length - 1].signature;
  }

  return txs;
};

getTxs(
  connection,
  new PublicKey("2Nzt8TYeAfgJDftKzkb7rgYShVvyXTR7cPVvpqaZ2a4V")
);

solana.py中的等效方法是 https://michaelhly.github.io/solana-py/rpc/pc/papi/#solana.rpc.api.client.get_signatures_for_address

You can use the getSignaturesForAddress RPC method on the mint address and walk backward to get all the transactions.

Here is an example in JS:

import {
  Connection,
  clusterApiUrl,
  ConfirmedSignatureInfo,
  PublicKey,
} from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));

export const getTxs = async (connection: Connection, pubkey: PublicKey) => {
  const txs: ConfirmedSignatureInfo[] = [];

  // Walk backward
  let lastTransactions = await connection.getConfirmedSignaturesForAddress2(
    pubkey
  );
  let before = lastTransactions[lastTransactions.length - 1].signature;
  txs.push(...lastTransactions);

  while (true) {
    const newTransactions = await connection.getConfirmedSignaturesForAddress2(
      pubkey,
      {
        before,
      }
    );
    if (newTransactions.length === 0) break;
    txs.push(...newTransactions);
    before = newTransactions[newTransactions.length - 1].signature;
  }

  return txs;
};

getTxs(
  connection,
  new PublicKey("2Nzt8TYeAfgJDftKzkb7rgYShVvyXTR7cPVvpqaZ2a4V")
);

The equivalent method in Solana.py is this one https://michaelhly.github.io/solana-py/rpc/api/#solana.rpc.api.Client.get_signatures_for_address

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文