75 |
77 |
78 |
79 | Future<EtherScanSupplyModel>
80 | tokenSupply
81 | (- {String? tokenName,
82 | - String? contractAddress}
83 |
)
84 |
85 |
86 |
87 | Returns the supply of Tokens
88 | tokenname - Name of the Token
89 | contractaddress - Address from token contract
90 | Example
91 | var supply = eth.tokenSupply(
92 | tokenname: null,
93 | contractAddress: '0x57d90b64a1a57749b0f932f1a3395792e12e7055'
94 | );
95 |
96 | Result returned in Wei, to get value in Ether divide resultAbove/1000000000000000000)
97 |
98 |
99 |
100 | Implementation
101 | Future<EtherScanSupplyModel> tokenSupply({
102 | String? tokenName,
103 | String? contractAddress,
104 | }) async {
105 | const module = 'stats';
106 | const action = 'tokensupply';
107 |
108 | Map<String, dynamic>? query = {
109 | 'module': module,
110 | 'action': action,
111 | 'apiKey': apiKey,
112 | };
113 |
114 | if (tokenName != null) {
115 | query.putIfAbsent('tokenname', () => tokenName);
116 | }
117 |
118 | if (contractAddress != null) {
119 | query.putIfAbsent('contractaddress', () => contractAddress);
120 | }
121 |
122 | return (await get(query)).fold(
123 | (l) => EtherScanSupplyModel.empty(),
124 | (r) => EtherScanSupplyModel.fromJson(r),
125 | );
126 | }
127 |
128 |
129 |
130 |
131 |
133 |
134 |