tronscan-client
TypeScript icon, indicating that this package has built-in type declarations

1.17.0 • Public • Published

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'
});
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);
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;
const response = await tronScanClient.getBlocks();
const blocks = response.data;
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

Package Sidebar

Install

npm i tronscan-client

Weekly Downloads

4

Version

1.17.0

License

MIT

Unpacked Size

196 kB

Total Files

9

Last publish

Collaborators

  • separski