1

I have a list of addresses, thousands, and I need to monitor incoming transactions to them. Some of them are native Solana addresses, other are tokens.

How will I get the last 3-5 transactions for a given address/account? The information I'll need is: assets, timestamp, value, from. That's, basic one.

How to do this? Does https://api.mainnet-beta.solana.com support it? I haven't found clear information.

P.S.

I'm using a language that's not a main-stream one, therefore I want to use an API for this rather than Solana SDK.

1 Answer 1

3

To get the last 1000 signatures for a specific address using the JSON RPC API, do the following:

curl https://api.mainnet-beta.solana.com/ \
  -X POST \
  -H "Content-Type: application/json" \
  -d $'[
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getSignaturesForAddress",
      "params": ["Vote111111111111111111111111111111111111111",{"before": "oldestSignaturesOfLastFetch"}]
      }
  ]'

The above gets signatures for the account Vote111111111111111111111111111111111111111 before the signature oldestSignaturesOfLastFetch. From that, you can then use the individual signatures to get the transaction information using getTransaction.

4
  • Does getSignaturesForAddress have to be used? Can't a list of TXs be fetched without it -- directly?
    – Kum
    Dec 29, 2022 at 21:09
  • No, you have to use getSignaturesForAddress first. I'm sure some saas has both combined, but raw JSON RPC API requires both
    – Jacob Creech
    Dec 30, 2022 at 2:17
  • But even after having received getSignaturesForAddress, one would have to request last N transactions one by one? There's no way to pull them all at once?
    – Kum
    Dec 30, 2022 at 2:29
  • You can batch them using JSON RPC batching
    – Jacob Creech
    Dec 30, 2022 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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