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).
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 .
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?
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?
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.
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)
You said itās currently available only on betanet. What are Algorandās plans about bringing this feature on mainnet and testnet?
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?
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!
Which SDK are you using?
When do you need the capability on TestNet and MainNet?
AlgoExplorer is managed by an independent company. The announced recently a v2.0: AlgoExplorer v2.0 is out!
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)
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.
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!
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!