1+ /**
2+ * Copyright 2024, BitGo, Inc. All Rights Reserved.
3+ */
4+ import { BitGoAPI } from '@bitgo/sdk-api' ;
5+ import { Trx } from '@bitgo/sdk-coin-trx' ;
6+ import * as fs from 'fs' ;
7+ require ( 'dotenv' ) . config ( { path : '../../.env' } ) ;
8+
9+ const bitgo = new BitGoAPI ( {
10+ accessToken : '' ,
11+ env : 'prod' ,
12+ } ) ;
13+
14+ const coin = 'trx' ;
15+ bitgo . register ( coin , Trx . createInstance ) ;
16+
17+ const walletId = '' ;
18+
19+ async function main ( ) {
20+ const wallet = await bitgo . coin ( coin ) . wallets ( ) . get ( { id : walletId } ) ;
21+ let prevId = undefined ;
22+ let index = 1 ;
23+
24+ do {
25+ const addresses = await wallet . addresses ( { includeBalances : true , prevId } ) ;
26+ prevId = addresses . nextBatchPrevId ;
27+
28+ for ( const { address, balance, needsConsolidation, tokenConsolidationState } of addresses . addresses ) {
29+ const { tokens, spendableBalanceString } = balance ;
30+ const usdtBalance = tokens [ 'trx:usdt' ] ?. spendableBalanceString ;
31+
32+ console . log ( `Address ${ index } : ${ address } ` ) ;
33+ console . log ( 'USDT token balance: ' , usdtBalance || 'Does not have USDT balance' ) ;
34+ console . log ( 'TRX balance: ' , spendableBalanceString ) ;
35+
36+ if ( usdtBalance > 0 && spendableBalanceString > 36000000 ) {
37+ const data = `${ address } , USDT balance: ${ usdtBalance } , TRX balance: ${ spendableBalanceString } , V1: ${ needsConsolidation } , V2: ${ tokenConsolidationState [ 'trx' ] } \n` ;
38+ fs . appendFileSync ( 'addresses-with-usdt-balance-and-trx-greater-than-36.txt' , data ) ;
39+ }
40+
41+ if ( ( ! usdtBalance || usdtBalance <= 0 ) && spendableBalanceString > 1000000 ) {
42+ const data = `${ address } , USDT balance: ${ usdtBalance } , TRX balance: ${ spendableBalanceString } , V1: ${ needsConsolidation } , V2: ${ tokenConsolidationState [ 'trx' ] } \n` ;
43+ fs . appendFileSync ( 'addresses-without-usdt-and-trx-greater-than-1.txt' , data ) ;
44+ }
45+
46+ index += 1 ;
47+ }
48+ } while ( prevId !== undefined ) ;
49+ }
50+
51+ main ( ) . catch ( ( e ) => console . error ( e ) ) ;
0 commit comments