Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9bb3355

Browse files
committed
README improvements
1 parente070c5a commit9bb3355

File tree

5 files changed

+72
-24
lines changed

5 files changed

+72
-24
lines changed

‎README.md‎

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[Etherscan](https://etherscan.io/apis) Java API implementation.
44

5+
Library supports all available EtherScan*API* calls for all available*Ethereum Networks*.
56

67
![](https://media.giphy.com/media/1msHfmVdtuwkXww4ZC/giphy.gif)
78

@@ -34,55 +35,107 @@ dependencies {
3435
-[Transactions](#transaction-api)
3536
-[Version History](#version-history)
3637

37-
##Overall
38-
39-
How all is linked together:
40-
4138
##Api Examples
4239

4340
You can read about all API methods on[Etherscan](https://etherscan.io/apis)
4441

45-
You can you API with you key or without key as well.
42+
*Library support all available EtherScan API.*
43+
44+
You can use API with you key or without key as well (Check API request\sec restrictions).
4645
```java
4746
EtherScanApi api=newEtherScanApi();
4847
EtherScanApi api=newEtherScanApi("YourApiKey");
4948
```
5049

50+
Below there are examples for each API category.
51+
5152
###Mainnet and Testnets
52-
API support:*MAINNET,ROPSTEN,KOVAN,RINKEBY* networks.
53+
API support Ethereum:*[MAINNET](https://etherscan.io),[ROPSTEN](https://ropsten.etherscan.io),[KOVAN](https://kovan.etherscan.io),[RINKEBY](https://rinkeby.etherscan.io)* networks.
5354
```java
5455
EtherScanApi api=newEtherScanApi(EthNetwork.MAINNET);
5556
EtherScanApi api=newEtherScanApi("YourApiKey",EthNetwork.KOVAN);
5657
```
5758

5859
###Account Api
59-
**Get Ether Balance for a single Address Example**
60+
**Get Ether Balance for a single Address**
6061
```java
6162
EtherScanApi api=newEtherScanApi();
6263
Balance balance= api.account().balance("0x8d4426f94e42f721C7116E81d6688cd935cB3b4F");
6364
```
6465

6566
###Block Api
67+
**Get uncles block for block height**
68+
```java
69+
EtherScanApi api=newEtherScanApi();
70+
Optional<UncleBlock> uncles= api.block().uncles(200000);
71+
```
6672

6773
###Contract Api
74+
**Request contract ABI from[verified codes](https://etherscan.io/contractsVerified)**
75+
```java
76+
EtherScanApi api=newEtherScanApi();
77+
Abi abi= api.contract().contractAbi("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413");
78+
```
6879

6980
###Logs Api
81+
**Get event logs for single topic**
82+
```java
83+
EtherScanApi api=newEtherScanApi();
84+
LogQuery query=LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
85+
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
86+
.build();
87+
List<Log> logs= api.logs().logs(query);
88+
```
89+
90+
**Get event logs for 3 topics with respectful operations**
91+
```java
92+
EtherScanApi api=newEtherScanApi();
93+
LogQuery query=LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c",379224,400000)
94+
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
95+
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
96+
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
97+
.setOpTopic0_1(LogOp.AND)
98+
.setOpTopic0_2(LogOp.OR)
99+
.setOpTopic1_2(LogOp.AND)
100+
.build();
101+
List<Log> logs= api.logs().logs(query);
102+
```
70103

71104
###Proxy Api
105+
**Get tx detailds with proxy endpoint**
106+
```java
107+
EtherScanApi api=newEtherScanApi(EthNetwork.MAINNET);
108+
Optional<TxProxy> tx= api.proxy().tx("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
109+
```
110+
111+
**Get block info with proxy endpoint**
112+
```java
113+
EtherScanApi api=newEtherScanApi(EthNetwork.MAINNET);
114+
Optional<BlockProxy> block= api.proxy().block(15215);
115+
```
72116

73117
###Stats Api
118+
**Statistic about last price**
119+
```java
120+
EtherScanApi api=newEtherScanApi();
121+
Price price= api.stats().lastPrice();
122+
```
74123

75124
###Transaction Api
76-
125+
**Request receipt status for tx**
126+
```java
127+
EtherScanApi api=newEtherScanApi();
128+
Optional<Boolean> status= api.txs().receiptStatus("0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76");
129+
```
77130

78131
###Token Api
79132
You can read account API[here](https://etherscan.io/apis#accounts)
80133

81-
Token API migrated to account & stats respectfully.
134+
Token APImethodsmigrated to[Account](#account-api) &[Stats](#stats-api) respectfully.
82135

83136
##Version History
84137

85-
**1.0.0** - Initial project with all API functionality.
138+
**1.0.0** - Initial project with all API functionality, for all available networks, with tests coverage for all cases.
86139

87140
##License
88141

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
packageio.api.etherscan;
22

3-
importio.api.etherscan.core.impl.EtherScanApi;
4-
importio.api.etherscan.model.Balance;
5-
importio.api.etherscan.model.EthNetwork;
6-
7-
/**
8-
*
9-
*/
103
publicclassApp {
114
publicstaticvoidmain(String[]args) {
12-
EtherScanApiapi =newEtherScanApi(EthNetwork.MAINNET);
13-
Balancebalance =api.account().balance("0x8d4426f94e42f721C7116E81d6688cd935cB3b4F");
14-
System.out.println("Test");
5+
156
}
167
}

‎src/main/java/io/api/etherscan/core/impl/EtherScanApi.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageio.api.etherscan.core.impl;
22

33
importio.api.etherscan.core.*;
4+
importio.api.etherscan.error.ApiException;
45
importio.api.etherscan.error.ApiKeyException;
56
importio.api.etherscan.executor.IHttpExecutor;
67
importio.api.etherscan.executor.impl.HttpExecutor;
@@ -54,14 +55,16 @@ public EtherScanApi(final String apiKey,
5455
if (BasicUtils.isBlank(apiKey))
5556
thrownewApiKeyException("API key can not be null or empty");
5657

58+
if(network ==null)
59+
thrownewApiException("Ethereum Network is set to NULL value");
60+
5761
// EtherScan 5request\sec limit support by queue manager
5862
finalIQueueManagermasterQueue = (apiKey.equals("YourApiKeyToken"))
5963
?newFakeQueueManager()
6064
:newQueueManager(5,1);
6165

6266
finalIHttpExecutorexecutor =executorSupplier.get();
63-
finalEthNetworkusedNetwork = (network ==null) ?EthNetwork.MAINNET :network;
64-
finalStringbaseUrl ="https://" +usedNetwork.getDomain() +".etherscan.io/api" +"?apikey=" +apiKey;
67+
finalStringbaseUrl ="https://" +network.getDomain() +".etherscan.io/api" +"?apikey=" +apiKey;
6568

6669
this.account =newAccountApiProvider(masterQueue,baseUrl,executor);
6770
this.block =newBlockApiProvider(masterQueue,baseUrl,executor);

‎src/main/java/io/api/etherscan/executor/impl/HttpExecutor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private String readData(final HttpURLConnection connection) throws IOException {
127127
}
128128

129129
privateInputStreamReadergetStreamReader(finalHttpURLConnectionconnection)throwsIOException {
130-
return ("gzip".equals(connection.getContentEncoding()))
130+
return (connection.getContentEncoding() !=null &&"gzip".equals(connection.getContentEncoding()))
131131
?newInputStreamReader(newGZIPInputStream(connection.getInputStream()),"utf-8")
132132
:newInputStreamReader(connection.getInputStream(),"utf-8");
133133
}

‎src/test/java/io/api/etherscan/EtherScanApiTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageio.api.etherscan;
22

33
importio.api.etherscan.core.impl.EtherScanApi;
4+
importio.api.etherscan.error.ApiException;
45
importio.api.etherscan.error.ApiKeyException;
56
importio.api.etherscan.model.EthNetwork;
67
importorg.junit.Assert;
@@ -35,7 +36,7 @@ public void blankKey() {
3536
EtherScanApiapi =newEtherScanApi(blankKey,network);
3637
}
3738

38-
@Test
39+
@Test(expected =ApiException.class)
3940
publicvoidnullNetwork() {
4041
EtherScanApiapi =newEtherScanApi(validKey,null);
4142
assertNotNull(api);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp