npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tronscan-client

v1.17.0

Published

A set of classes to work with tron-compatible blockchain observers

Downloads

399

Readme

https://tronscan.org/

Tronscan client

Client for receiving blockchain data through block explorers (in particular, tronscan).
At the moment, the number of available methods is limited to those indicated in the examples below.

Donation

To support this project, you can send crypto to:

  • 0x3F2f0098310e654040f7794AB7E44Ac48E0eaF7B
  • TLPh66vQ2QMb64rG3WEBV5qnAhefh2kcdw

Create client instance

import { TronScanClient } from 'tronscan-client';

const tronScanClient = new TronScanClient({
  url: 'https://apilist.tronscanapi.com/api',
  apiKey: 'your_api_key_from_tronscan_cabinet'
});

Account section

const ADDRESS = 'tron_address';
const FROM_ADDRESS = 'from_address';
const TOKEN_ADDRESS = 'token_address';

// Get account list:
const response = await tronScanClient.getAccountList();
console.log(response.data);

// Get account detail information:
const account = await tronScanClient.getAccountDetailInformation({
  address: ADDRESS
});
console.log(account);

// Get token list:
const accountTokensList = await tronScanClient.getTokenList({
  address: ADDRESS
});
console.log(accountTokensList);

// Get the voted list:
const votedList = await tronScanClient.getVotedList({
  candidate: ADDRESS
});
console.log(votedList.data);

// Get a list of account resources:
const resourcesList = await tronScanClient.getAccountResourcesList({
  address: ADDRESS
});
console.log(resourcesList.data);

// Get a list of stake 2.0 account resources:
const resourcesStake2List = await tronScanClient.getAccountResourcesStake2List({
  address: ADDRESS
});
console.log(resourcesStake2List.data);

// Get approval list:
const approvalList = await tronScanClient.getApprovalList({
  address: ADDRESS
});
console.log(approvalList);

// Get account authorization change records:
const accountAccessChangeRecords = await tronScanClient.getAccountAuthChangeRecords({
  contract_address: TOKEN_ADDRESS,
  from_address: FROM_ADDRESS,
  to_address: ADDRESS,
  type: 'approve'
});
console.log(accountAccessChangeRecords);

// Get list of daily analytics data for an account over time:
const accountDailyAnalytics = await tronScanClient.getAccountDailyAnalytics({
  address: ADDRESS,
  start_timestamp: 1514764800000
});
console.log(accountDailyAnalytics);

Tokens section

Transactions and transfers section

const ADDRESS = 'tron_address';

// Get a list of transactions:
const response = await tronScanClient.getTransactionsList({
  address: ADDRESS
});
const txs = response.data;

// Get transaction detail information by transaction hash
const [tx] = txs;
const txDetails = await tronScanClient.getTransactionDetailByHash({
  hash: tx.hash
});

// Get trx&trc10 transfer list:
const response = await tronScanClient.getTrxTrc10TransferList({
  address: ADDRESS,
  start_timestamp: 1715855574000,
  end_timestamp: 1715855574000
});
const txs = response.data;

// Get trc20&721 transfers list:
const response = await tronScanClient.getTrc20Trc721TransferList({
  relatedAddress: ADDRESS
});
const transfers = response.token_transfers;

// Get only trx transfers:
const response = await tronScanClient.getTrxTransfers({
  address: ADDRESS
});
const transfers = response.data;

// Get only trc10 transfers:
const response = await tronScanClient.getTrc10Transfers({
  address: ADDRESS
});
const transfers = response.data;

// Get only trc20 transfers:
const response = await tronScanClient.getTrc20Transfers({
  relatedAddress: ADDRESS,
  contract_address: 'contract_address'
});
const transfers = response.data;

Block section

const response = await tronScanClient.getBlocks();
const blocks = response.data;

Security Service API section

const ADDRESS = 'tron_address';
const TOKEN_ADDRESS = 'token_address';
const TX_HASH = 'some_tx_hash';
const URL = 'www.google.com.hk';

// Check account security:
const accountSecurity = await tronScanClient.checkAccountSecurity({
  address: ADDRESS
});
console.log(accountSecurity);

// Check token security:
const tokenSecurity = await tronScanClient.checkTokenSecurity({
  address: TOKEN_ADDRESS
});
console.log(tokenSecurity);

// Check url security:
const urlSecurity = await tronScanClient.checkUrlSecurity({
  url: URL
});
console.log(urlSecurity);

// Check transactions security:
const txsSecurity = await tronScanClient.checkTransactionsSecurity({
  hashes: TX_HASH
});
console.log(txsSecurity);

// Check multi sign security:
const multiSignSecurity = await tronScanClient.checkMultiSignSecurity({
  address: ADDRESS
});
console.log(multiSignSecurity);

// Check account authorization security:
const accountAuthSecurity = await tronScanClient.checkAccountAuthSecurity({
  address: ADDRESS
});
console.log(accountAuthSecurity);

// Get all tokens in TronScan:
const tokensList = await tronScanClient.getAllTokens({
  limit: 1,
  start: 0
});
console.log(tokensList);

Supported networks table

You must use the API key!!!
Just register an account on tronscan.org and generate an API key.

| Name | Block explorer | Block explorer API url | | --------------- | ---------------------------- | ----------------------------------- | | Tronscan | https://tronscan.org/ | https://apilist.tronscanapi.com/api | | Tronscan Nile | https://nile.tronscan.org/ | https://nileapi.tronscan.org/api | | Tronscan Shasta | https://shasta.tronscan.org/ | https://shastapi.tronscan.org/api |