I want to the asset transacation to be displayed on fromtend and I want to fetch it from the blcokchain.
I am working in the sandbox environment.
How can I do that here
const algosdk = require('algosdk');
const assetId = <your asset ID>;
const algodToken = '<your algod token>';
const algodServer = 'http://localhost:4001';
async function getAssetHistory() {
const algodClient = new algosdk.Algodv2(algodToken, algodServer);
const assetTransactions = await algodClient.transactionByAsset(
assetId,
0,
1000, // retrieve up to 1000 transactions
1, // include asset transfer transactions
1, // include asset configuration transactions
1, // include asset destroy transactions
undefined // do not filter by sender address
);
return assetTransactions.transactions;
}
async function main() {
const transactions = await getAssetHistory();
console.log('Transactions:', transactions);
}
main().catch((err) => console.log(err));```
This is a code I got somewhere can I use this?
Please help
If there is any link please do share