File tree 2 files changed +56
-0
lines changed
2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -538,4 +538,38 @@ export class EtherscanApi extends EtherscanRequest {
538
538
gas
539
539
} )
540
540
}
541
+
542
+ /**
543
+ * Get ERC20-Token TotalSupply by ContractAddress
544
+ * @param {string } contractAddress
545
+ * @return {Promise<string> }
546
+ */
547
+ public async getTokenByContractAddress (
548
+ contractAddress : string
549
+ ) : Promise < string > {
550
+ return this . createRequest ( {
551
+ module : MODULES . STATS ,
552
+ action : ACTIONS . GET_TOKEN_BY_CONTRACT ,
553
+ contractaddress : contractAddress
554
+ } )
555
+ }
556
+
557
+ /**
558
+ * Get ERC20-Token Account Balance for TokenContractAddress
559
+ * @param {string } contractAddress
560
+ * @return {Promise<string> }
561
+ */
562
+ public async getTokenBalanceByContractAddress (
563
+ contractAddress : string ,
564
+ address : string ,
565
+ tag : string = 'latest'
566
+ ) : Promise < string > {
567
+ return this . createRequest ( {
568
+ module : MODULES . ACCOUNT ,
569
+ action : ACTIONS . GET_TOKEN_BALANCE_BY_CONTRACT ,
570
+ contractaddress : contractAddress ,
571
+ address,
572
+ tag
573
+ } )
574
+ }
541
575
}
Original file line number Diff line number Diff line change
1
+ const EtherscanAPI = require ( '../build' )
2
+
3
+ describe ( 'Etherscan tokens methods' , ( ) => {
4
+ const e = new EtherscanAPI ( )
5
+
6
+ test ( 'getTokenByContractAddress' , async ( ) => {
7
+ const data = await e . getTokenByContractAddress (
8
+ '0x57d90b64a1a57749b0f932f1a3395792e12e7055'
9
+ )
10
+
11
+ expect ( isNaN ( Number ( data ) ) ) . toBe ( false )
12
+ } )
13
+
14
+ test ( 'getTokenBalanceByContractAddress' , async ( ) => {
15
+ const data = await e . getTokenBalanceByContractAddress (
16
+ '0x57d90b64a1a57749b0f932f1a3395792e12e7055' ,
17
+ '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
18
+ )
19
+
20
+ expect ( isNaN ( Number ( data ) ) ) . toBe ( false )
21
+ } )
22
+ } )
You can’t perform that action at this time.
0 commit comments