ASA - Transaction list

Is there a way to get transaction list for an asset ID?

For eg:
If I have an assetID = 3521

I want to get all the transaction involving this assetID(3521).

The GoalSeeker website, https://goalseeker.purestake.com will allow you do this with their search. For example the Tether USDT Asset: https://goalseeker.purestake.io/algorand/mainnet/asset/312769 .

1 Like

You can get them from algoexplorer.io from the UI:
https://algoexplorer.io/asset/312769

Are you looking to get this information as a user or developer?

1 Like

Thanks for the info @Tim.

@pipaman. I am looking it as a developer.

Hello, I want to recover this thread because as a developer I don’t actually find an answer to the question.

I’m interested in understanding how services like goalseeker retrieve that information, what’s the procedure using the SDK?

1 Like

Block explorers usually read each block one by one and create their own databases.

The current v1.0 API does not directly give you access to the list of transactions of a given ASA (except if you are willing to do what block explorers are doing).

However, the brand new Indexer v2 should allow you to get easy access to this list of transactions.
It is only working on BetaNet right now.

Hello @fabrice, thanks for your always kind answers.

  1. I’ve updated my SDK to version 1.3.0, however I still don’t see the class v2client with access to the indexer. How am I suppose to configure the client in such a way that I can get access to those functions? (for instance via purestake)

  2. You said it’s currently available only on betanet. What are Algorand’s plans about bringing this feature on mainnet and testnet?

  3. I’ve just saw you’ve just updated the explorer, isn’t there any api I can use which would return the list I’m trying to extract?

  4. Beside storing the information I need in a centralized database, what alternative solutions would you suggest me in order to retrieve the historical transactions of an asset?

Thanks!

  1. Which SDK are you using?

  2. When do you need the capability on TestNet and MainNet?

  3. AlgoExplorer is managed by an independent company. The announced recently a v2.0: AlgoExplorer v2.0 is out!

  4. The three solutions you have right now:
    a. using Indexer v2 (BetaNet only, but soon TestNet and MainNet). If you can wait, this is the most “Algorand”-way to do it
    b. creating your own block explorer and store in your own database
    c. using an external block explorer API (such as AlgoExplorer)

  1. I was referring to the python sdk, but I’d like to be able to perform the same process with javascript.
  2. At the moment in my company we are at PoC stage, so developing on betanet would be fine, I just want to make sure that you plan to bring the feature on mainnet too.
  3. Yes, I saw that, it’s cool, but still I can’t find an API helping to solve the problem. I know I can see the information displayed in a page, but I would like to retrieve an object / array for development.
  4. Solution a is the one I would like to go for, but as I was mentioning I’m having quite a hard time trying to figure out how to do it.

PureStake will offer the new Indexer API soon, within a week or two for all three ledgers (MainNet, TestNet, BetaNet). Keep an eye for an announcement email. BetaNet may be ready earlier, I’ll post here if it is.

1 Like

You can use AlgoExplorer API, these APIs are not documented yet but they have been working for months. We plan to change the URLs, that is why they are not part of current release.

But you can use them:
https://api.algoexplorer.io/v1/transaction/asset/:assetId/latest/100
https://api.testnet.algoexplorer.io/v1/transaction/asset/:assetId/latest/100
https://api.betanet.algoexplorer.io/v1/transaction/asset/:assetId/latest/100

And you can page the transactions with this URL:
https://:network/v1/transaction/asset/:assetId/from/:fromIndex/to/:toIndex

For example, you can get last 100 USDt:
https://api.algoexplorer.io/v1/transaction/asset/312769/latest/100

Para paginar las txs, esta url te da las transactions con index 1 a 99:
https://api.algoexplorer.io/v1/transaction/asset/312769/from/1/to/99

Thank you @Tim and @pipaman, this is very helpful!

Anyone can go further about the solution @fabrice was talking about? There is a way to do this using the SDK when you connect to BetaNet, isn’t there? Did I get it wrong?

Thanks!

1 Like

BetaNet was upgraded last week to include the V2 Algod API.

In addition a new standalone Indexer, V2 was released at the same time that has its own API now. To do things like search assets and see lists of asset transactions, you need access to the Indexer V2 API.

You can see the new V2 client code for both Algod and Indexer here in the JS repo (https://github.com/algorand/js-algorand-sdk/tree/d36f52a154ff975344f9a9889bf03474ecd87bae/src/client/v2) version 1.6.1 at npm. The master branch at Github is only at 1.6.0.

Once the SDK is imported you’d declare an indexer client like this in you script let indexerClient = new algosdk.Indexer(indexer_token, indexer_server, indexer_port); // new

The Indexer V2 swagger file explaining the new features is available here - https://github.com/algorand/indexer/blob/develop/api/indexer.oas2.json.

Thank you @Tim, I managed to install the updated SDK and to to find the new classes, but apparently I’m missing something because I’m unable to make them do anything.
I read the code on github but without a proper documentation and examples it’s kinda hard to understand how to make them work.

For instance, I tried indexerClient.lookupAssetByID(1234) (using a valid ID) but it returns:

LookupAssetByID {
c:
HTTPClient {
address: ‘https://betanet-algorand.api.purestake.io/ps1’,
token: { ‘X-API-Key’: ‘myApiKey’ },
defaultHeaders: {},
get: [AsyncFunction],
post: [AsyncFunction],
delete: [AsyncFunction] },
index: 1234 }

How am I supposed to make it work?

We haven’t released our support for the new indexer yet! I’ll be posting here once we do.

Note, in the new V2 code in many places instead of calling a function directly, there are classes, and you use a do() method to actually exercise the code.

For example, to get transaction parameters in Algod V2 - let params = await algodClient.getTransactionParams().do(); vs in Algod V1 let params = await algodClient.getTransactionParams();.

What you are seeing in the pasted example is the HTTPclient that is passed to the class constructor .

Alright, so I’ll wait for the indexer to be supported because it doesn’t work with .do() either:

indexerClient.searchForAssets().do(12345).then( res => asset = res).catch( err => console.log(err))
Promise {
,
domain:
Domain {
domain: null,
_events:
[Object: null prototype] {
removeListener: [Function: updateExceptionCapture],
newListener: [Function: updateExceptionCapture],
error: [Function: debugDomainError] },
_eventsCount: 3,
_maxListeners: undefined,
members: ,
[Symbol(kWeak)]: WeakReference {} } }
TypeError: field.toLowerCase is not a function
at RequestBase.set (/home/drew18/algorand/js-sdk-test/node_modules/superagent/lib/request-base.js:342:22)
at HTTPClient.get (/home/drew18/algorand/js-sdk-test/node_modules/algosdk/src/client/client.js:32:18)
at SearchForAssets.do (/home/drew18/algorand/js-sdk-test/node_modules/algosdk/src/client/v2/indexer/searchForAssets.js:13:26)
at repl:1:35
at Script.runInThisContext (vm.js:122:20)
at REPLServer.defaultEval (repl.js:332:29)
at bound (domain.js:402:14)
at REPLServer.runBound [as eval] (domain.js:415:12)
at REPLServer.onLine (repl.js:642:10)
at REPLServer.emit (events.js:203:15)

Thank you in the meanwhile!

The issue there is where the value goes, it’s actually in child methods and not the do() call. Below is working code that gets a block info and returns assets (against a private indexer v2 api).

const baseServer = "";
const port = "";

const token = {
    'X-API-key' : '',
}

let indexerClient = new algosdk.Indexer(token, baseServer, port);
let algodClient = new algosdk.Algodv2(token, baseServer, port);

(async()=> {
    let blockInfo = await indexerClient.lookupBlock(5).do()
    console.log(blockInfo)
    
    let assetInfo = await indexerClient.searchForAssets().limit(1).name('latikum22').do()
    console.log(assetInfo.assets)

})().catch(e => {
    console.log(e);
});

Note: I edited this after realizing on closer examination how the query is formed.

I tried the “searchForAssets” one built in the same way as you did but I still receive:

Error: Forbidden
at Request.callback (/home/drew18/algorand/js-sdk-test/node_modules/superagent/lib/node/index.js:804:15)
at parser (/home/drew18/algorand/js-sdk-test/node_modules/superagent/lib/node/index.js:1036:18)
at IncomingMessage.res.on (/home/drew18/algorand/js-sdk-test/node_modules/superagent/lib/node/parsers/json.js:19:7)
at IncomingMessage.emit (events.js:203:15)
at IncomingMessage.EventEmitter.emit (domain.js:448:20)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

Edit: I’m using BetaNet throught purestake, if that can be helpful.

PS: how can I format the text for code? On the panel I only have quote and preformatted text.

H1 @drew … algosdk.Algodv2 is not needed to do searching using the indexer. Only algosdk.Indexer is . Not sure if this is the problem, but how are you accessing the Indexer DB? We have recently published some docs on this… to setup indexer DB see this https://developer.algorand.org/docs/run-a-node/setup/indexer/ … This will take some time and I am looking forward to Purestake’s service on this which looks to be about a week out @Tim ? And to use it see https://developer.algorand.org/docs/features/indexer/

I have code samples which will be merged soon to that link. The JavaScript ones are currently located here. https://github.com/algorand-devrel/hackathon/tree/master/algorandsamples/myjsdemo/Indexer … these match up to the curl commands on feature link. Hope these resources help, and was not sure if you knew about them as they are recent.

Not the problem, I’m configuring the indexer using my purestake token as indicated by @Tim

I saw that but since I’m connecting to the BetaNet through purestake why should I care about setting up a node on my machine?

Does this mean that the BetaNet I’m connecting to through purestake does not support the indexer yet?

Thank you for your kind support!