Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c14ca8

Browse filesBrowse files
committed
Merge branch 'release/stats'
2 parents 9bfa2ea + 2364aee commit 1c14ca8
Copy full SHA for 1c14ca8

File tree

Expand file treeCollapse file tree

3 files changed

+287
-23
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+287
-23
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8+
## [1.3.5] - 2021-11-03
9+
### Added
10+
- Stats actions
11+
812
## [1.3.4] - 2021-11-03
913
### Added
1014
- Gas Tracker actions

‎lib/Etherscan/APIConf.php

Copy file name to clipboardExpand all lines: lib/Etherscan/APIConf.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ class APIConf
3030
self::BLOCK_TYPE_BLOCKS, self::BLOCK_TYPE_UNCLES
3131
];
3232

33+
const CLIENT_TYPE_GETH = "geth";
34+
const CLIENT_TYPE_PARITY = "parity";
35+
public static $clientTypes = [
36+
self::CLIENT_TYPE_GETH, self::CLIENT_TYPE_PARITY
37+
];
38+
39+
const SYNC_MODE_DEFAULT = "default";
40+
const SYNC_MODE_ARCHIVE = "archive";
41+
public static $syncModes = [
42+
self::SYNC_MODE_DEFAULT, self::SYNC_MODE_ARCHIVE
43+
];
44+
3345
/**
3446
* Returns API URL
3547
*

‎lib/Etherscan/Api/Stats.php

Copy file name to clipboardExpand all lines: lib/Etherscan/Api/Stats.php
+271-23Lines changed: 271 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,313 @@
22

33
namespace Etherscan\Api;
44

5+
use Etherscan\APIConf;
6+
use Etherscan\Exception\ErrorException;
7+
use Etherscan\Exception\InvalidArgumentException;
8+
59
/**
610
* Class Stats
711
* @package Etherscan\Api
812
* @author Maslakou Ihar <igormaslakoff@gmail.com>
913
*/
1014
class Stats extends AbstractApi
1115
{
16+
/**
17+
* Get Total Supply of Ether.
18+
* Returns the current amount of Ether in circulation.
19+
*
20+
* @return array Result returned in Wei, to get value in Ether divide resultAbove / 1000000000000000000
21+
* @throws \Etherscan\Exception\ErrorException
22+
*/
23+
public function ethSupply()
24+
{
25+
return $this->request->exec([
26+
'module' => "stats",
27+
'action' => "ethsupply",
28+
]);
29+
}
30+
/**
31+
* Get Total Supply of Ether 2
32+
* Returns the current amount of Ether in circulation, ETH2 Staking rewards and EIP1559 burnt fees statistics.
33+
*
34+
* @return array Result returned in Wei, to get value in Ether divide resultAbove / 1000000000000000000
35+
* @throws \Etherscan\Exception\ErrorException
36+
*/
37+
public function eth2Supply()
38+
{
39+
return $this->request->exec([
40+
'module' => "stats",
41+
'action' => "ethsupply2",
42+
]);
43+
}
1244

1345
/**
14-
* Get Token TotalSupply by TokenName (Supported TokenNames: DGD, MKR,
15-
* FirstBlood, HackerGold, ICONOMI, Pluton, REP, SNGLS).
46+
* Get Ether LastPrice Price.
47+
* Returns the latest price of 1 ETH.
1648
*
17-
* or
49+
* @return array
50+
* @throws \Etherscan\Exception\ErrorException
51+
*/
52+
public function ethPrice()
53+
{
54+
return $this->request->exec([
55+
'module' => "stats",
56+
'action' => "ethprice",
57+
]);
58+
}
59+
60+
/**
61+
* Get Ethereum Nodes Size
62+
* Returns the size of the Ethereum blockchain, in bytes, over a date range.
1863
*
19-
* by ContractAddress.
64+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
65+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
66+
* @param string $clienttype the Ethereum node client to use, either geth or parity
67+
* @param string $syncmode the type of node to run, either default or archive
68+
* @param string $sort 'asc' or 'desc'
2069
*
21-
* @param string $tokenIdentifier Token name from the list or contract address.
70+
* @return array
71+
* @throws \Etherscan\Exception\ErrorException
72+
* @throws \Etherscan\Exception\InvalidArgumentException
73+
*/
74+
public function getNodesSize($startdate, $enddate, $clienttype, $syncmode, $sort = "asc")
75+
{
76+
if (!in_array($clienttype, APIConf::$clientTypes)) {
77+
throw new InvalidArgumentException("Invalid client type");
78+
}
79+
80+
if (!in_array($syncmode, APIConf::$syncModes)) {
81+
throw new InvalidArgumentException("Invalid sync mode type");
82+
}
83+
84+
return $this->request->exec([
85+
'module' => "stats",
86+
'action' => "chainsize",
87+
'startdate' => $startdate,
88+
'enddate' => $enddate,
89+
'clienttype' => $clienttype,
90+
'syncmode' => $syncmode,
91+
'sort' => $sort
92+
]);
93+
}
94+
95+
/**
96+
* Get Total Nodes Count
97+
* Returns the total number of discoverable Ethereum nodes.
2298
*
2399
* @return array
24100
* @throws \Etherscan\Exception\ErrorException
25101
*/
26-
public function tokenSupply($tokenIdentifier) {
27-
$params = [
102+
public function getNodesCount()
103+
{
104+
return $this->request->exec([
28105
'module' => "stats",
29-
'action' => "tokensupply",
30-
];
106+
'action' => "nodecount",
107+
]);
108+
}
31109

32-
if (strlen($tokenIdentifier) === 42) {
33-
$params['contractaddress'] = $tokenIdentifier;
34-
} else {
35-
$params['tokenname'] = $tokenIdentifier;
36-
}
110+
/**
111+
* Get Daily Network Transaction Fee
112+
* Returns the amount of transaction fees paid to miners per day.
113+
*
114+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
115+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
116+
* @param string $sort 'asc' or 'desc'
117+
*
118+
* @return array
119+
* @throws \Etherscan\Exception\ErrorException
120+
*/
121+
public function getDailyTransactionFee($startdate, $enddate, $sort = "asc")
122+
{
123+
return $this->request->exec([
124+
'module' => "stats",
125+
'action' => "dailytxnfee",
126+
'startdate' => $startdate,
127+
'enddate' => $enddate,
128+
'sort' => $sort
129+
]);
130+
}
37131

38-
return $this->request->exec($params);
132+
/**
133+
* Get Daily New Address Count
134+
* Returns the number of new Ethereum addresses created per day.
135+
*
136+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
137+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
138+
* @param string $sort 'asc' or 'desc'
139+
*
140+
* @return array
141+
* @throws \Etherscan\Exception\ErrorException
142+
*/
143+
public function getDailyNewAddressCount($startdate, $enddate, $sort = "asc")
144+
{
145+
return $this->request->exec([
146+
'module' => "stats",
147+
'action' => "dailynewaddress",
148+
'startdate' => $startdate,
149+
'enddate' => $enddate,
150+
'sort' => $sort
151+
]);
39152
}
40153

41154
/**
42-
* Get Total Supply of Ether.
155+
* Get Daily Network Utilization
156+
* Returns the daily average gas used over gas limit, in percentage.
43157
*
44-
* @return array Result returned in Wei, to get value in Ether divide resultAbove / 1000000000000000000
158+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
159+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
160+
* @param string $sort 'asc' or 'desc'
161+
*
162+
* @return array
45163
* @throws \Etherscan\Exception\ErrorException
46164
*/
47-
public function ethSupply() {
165+
public function getDailyNetworkUtilization($startdate, $enddate, $sort = "asc")
166+
{
48167
return $this->request->exec([
49168
'module' => "stats",
50-
'action' => "ethsupply",
169+
'action' => "dailynetutilization",
170+
'startdate' => $startdate,
171+
'enddate' => $enddate,
172+
'sort' => $sort
51173
]);
52174
}
53175

54176
/**
55-
* Get Ether LastPrice Price.
177+
* Get Daily Average Network Hash Rate
178+
* Returns the historical measure of processing power of the Ethereum network.
179+
*
180+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
181+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
182+
* @param string $sort 'asc' or 'desc'
56183
*
57184
* @return array
58185
* @throws \Etherscan\Exception\ErrorException
59186
*/
60-
public function ethPrice() {
187+
public function getDailyAverageHashRate($startdate, $enddate, $sort = "asc")
188+
{
61189
return $this->request->exec([
62190
'module' => "stats",
63-
'action' => "ethprice",
191+
'action' => "dailyavghashrate",
192+
'startdate' => $startdate,
193+
'enddate' => $enddate,
194+
'sort' => $sort
195+
]);
196+
}
197+
198+
/**
199+
* Get Daily Transaction Count
200+
* Returns the number of transactions performed on the Ethereum blockchain per day.
201+
*
202+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
203+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
204+
* @param string $sort 'asc' or 'desc'
205+
*
206+
* @return array
207+
* @throws \Etherscan\Exception\ErrorException
208+
*/
209+
public function getDailyTransactionCount($startdate, $enddate, $sort = "asc")
210+
{
211+
return $this->request->exec([
212+
'module' => "stats",
213+
'action' => "dailytx",
214+
'startdate' => $startdate,
215+
'enddate' => $enddate,
216+
'sort' => $sort
217+
]);
218+
}
219+
220+
/**
221+
* Get Daily Average Network Difficulty
222+
* Returns the historical mining difficulty of the Ethereum network.
223+
*
224+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
225+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
226+
* @param string $sort 'asc' or 'desc'
227+
*
228+
* @return array
229+
* @throws \Etherscan\Exception\ErrorException
230+
*/
231+
public function getDailyAverageNetworkDifficulty($startdate, $enddate, $sort = "asc")
232+
{
233+
return $this->request->exec([
234+
'module' => "stats",
235+
'action' => "dailyavgnetdifficulty",
236+
'startdate' => $startdate,
237+
'enddate' => $enddate,
238+
'sort' => $sort
239+
]);
240+
}
241+
242+
/**
243+
* Get Ether Historical Daily Market Cap
244+
* Returns the historical Ether daily market capitalization.
245+
*
246+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
247+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
248+
* @param string $sort 'asc' or 'desc'
249+
*
250+
* @return array
251+
* @throws \Etherscan\Exception\ErrorException
252+
*/
253+
public function getDailyMarketCap($startdate, $enddate, $sort = "asc")
254+
{
255+
return $this->request->exec([
256+
'module' => "stats",
257+
'action' => "ethdailymarketcap",
258+
'startdate' => $startdate,
259+
'enddate' => $enddate,
260+
'sort' => $sort
261+
]);
262+
}
263+
264+
/**
265+
* Get Ether Historical Price
266+
* Returns the historical price of 1 ETH.
267+
*
268+
* @param string $startdate the starting date in yyyy-MM-dd format, eg. 2019-02-01
269+
* @param string $enddate the ending date in yyyy-MM-dd format, eg. 2019-02-28
270+
* @param string $sort 'asc' or 'desc'
271+
*
272+
* @return array
273+
* @throws \Etherscan\Exception\ErrorException
274+
*/
275+
public function getHistoricalPrice($startdate, $enddate, $sort = "asc")
276+
{
277+
return $this->request->exec([
278+
'module' => "stats",
279+
'action' => "ethdailyprice",
280+
'startdate' => $startdate,
281+
'enddate' => $enddate,
282+
'sort' => $sort
64283
]);
65284
}
66-
}
285+
286+
/**
287+
* Get Token TotalSupply by TokenName (Supported TokenNames: DGD, MKR,
288+
* FirstBlood, HackerGold, ICONOMI, Pluton, REP, SNGLS).
289+
*
290+
* or
291+
*
292+
* by ContractAddress.
293+
*
294+
* @param string $tokenIdentifier Token name from the list or contract address.
295+
*
296+
* @return array
297+
* @throws \Etherscan\Exception\ErrorException
298+
*/
299+
public function tokenSupply($tokenIdentifier)
300+
{
301+
$params = [
302+
'module' => "stats",
303+
'action' => "tokensupply",
304+
];
305+
306+
if (strlen($tokenIdentifier) === 42) {
307+
$params['contractaddress'] = $tokenIdentifier;
308+
} else {
309+
$params['tokenname'] = $tokenIdentifier;
310+
}
311+
312+
return $this->request->exec($params);
313+
}
314+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.