Socket
Book a DemoInstallSign in
Socket

@agrotokenlabs/algorand-reader

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agrotokenlabs/algorand-reader

An algorand reader for blockchain

1.0.4
latest
npmnpm
Version published
Maintainers
3
Created
Source

Algorand Reader v1.0.4

Algorand reader provides a set of functions to read the Algorand blockchain status. It allows to get balances, check opt-in, get nft metadata ARC-69 compliant and more.

Installing

Install the package

npm install algorand-reader

Requisites

Most of the functions uses an Algodv2 client and an Indexer client, you could set up a sandbox or use an external provider.

// Algodv2 client using sandbox
const token = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
const server = 'http://localhost'
const port = 4001
const algodClient = new algosdk.Algodv2(token, server, port)

// Indexer client using sandbox
const token = ''
const server = 'http://localhost'
const port = 8980
const indexerClient = new algosdk.Indexer(token, server, port)

// Algodv2 client using a provider like AlgoNode on testnet
const token = ''
const server = 'https://testnet-api.algonode.cloud'
const port = 443
const client = new algosdk.Algodv2(token, server, port)

// Indexer client using a provider like AlgoNode on testnet
const token = ''
const server = 'https://testnet-idx.algonode.cloud'
const port = 443
const indexerClient = new algosdk.Indexer(token, server, port)

Examples

Get account balance and min balance

import * as reader from 'algorand-reader'

const address = 'SXPXEGTVZBIU56NDZC6HA3HZVHAD7CSYECQ2RIKYLMB6KOG43K7UBRGFPI'

const token = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
const server = 'http://localhost'
const port = 4001
const client = new algosdk.Algodv2(token, server, port)

// Check if an account is valid
await reader.validateAddress(address)

// Get balance in algos
await reader.getBalanceAlgos(client, address)

// Get balance in microalgos
await reader.getBalanceMicroalgos(client, address)

// Get min balance
await reader.getMinBalance(client, address)

Get asa account balance and check if the account is opt-in

const asaId = 113619241

// Get created asset by an account
await reader.getCreatedAssets(client, address)

// Get asa balance from an account
await reader.getAsaBalance(client, address, asaId)

// Check if the account is opted-in to an asa
await reader.isOptIn(client, address, asaId)

// Get circulating supply of an asa
await reader.getTokenCirculatingSupply(client, testId)

Get metadata from an asa with ARC-69 standard

const token = ''
const server = 'http://localhost'
const port = 8980
const indexerClient = new algosdk.Indexer(token, server, port)

const nftId = 117345116

// Get metadata from the NFT
await reader.getAssetMetadata(indexerClient, nftId)

Feel free to file issues, PR and make suggestions, Thanks! 🚀

Keywords

algorand

FAQs

Package last updated on 27 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.