1

Is there a way to fetch transactions that involve a certain wallet AND token address?

Meaning, any transaction(sale, mint, etc) that occurred between the two.

I've tried filtering manually using @solana/web3.js' getSignaturesForAddress paired with getParsedTransactions - However, it seems like too much fetching and data manipulation to get to the desired result.

Perhaps there's a 3rd party API that offers a similar/more convenient endpoint for this use case? Or a simpler way to get this data?

Thank you.

1
  • Without using a 3rd party API, you already have the right answer, and you'll have to sift through the transactions
    – Jon C
    Commented Jan 11 at 0:33

1 Answer 1

1

Use getSignaturesForAddress on the token ATA.

import { getAssociatedTokenAddressSync } from '@solana/spl-token';
import { Connection, PublicKey } from '@solana/web3.js';

async function getTxsByToken(conn: Connection, mint: PublicKey, wallet: PublicKey) {
    const ata = getAssociatedTokenAddressSync(mint, wallet);
    return conn.getSignaturesForAddress(ata);
}

Note that there might be other token accounts (non ATA) that you would miss with this approach.

2
  • I thought of using accounts, but then a different issue arises, where any account that was closed will not be queried. So looking for a solution that is transaction based rather than account based. Thanks for the response though!
    – yoyo
    Commented Jan 6 at 17:12
  • this one might work then, it has a mint filter: docs.solana.fm/reference/get_account_transactions_from_master
    – lameren
    Commented Jan 9 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.