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

[2.0.0]#25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
GoodforGod merged 44 commits intomasterfromdev
May 17, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
44 commits
Select commitHold shift + click to select a range
a039cff
[2.0.0-SNAPSHOT]
GoodforGodMar 29, 2022
1559a3f
added support for txsToken with contract address too
abhaygupta1999Jul 21, 2022
9fb7d91
gas tracker API implementation
abhaygupta1999Nov 14, 2022
2174387
debug url
abhaygupta1999Nov 14, 2022
bf59b71
fixed gas oracle base url
abhaygupta1999Nov 14, 2022
c462175
removed sout
abhaygupta1999Nov 14, 2022
f3d6858
[2.0.0-SNAPSHOT]
GoodforGodMay 11, 2023
9e4d21a
Merge pull request #23 from abhaygupta1999/master
GoodforGodMay 13, 2023
7436509
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
420c68f
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
b9a8dda
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
fe444f4
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
192cb5b
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
0cafb6d
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
34ca1a7
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
f095f0f
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
70cee44
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
43a0693
[2.0.0-SNAPSHOT]
GoodforGodMay 13, 2023
9b366c3
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
bf9f02b
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
55788d5
[2.0.0-SNAPSHOT]
guggioJul 17, 2022
8ec7d93
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
a9dd8e0
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
225b211
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
aa25129
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
873f582
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
1beaafd
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
948a6f3
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
3210c39
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
f5b2edb
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
25751ab
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
47e04a8
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
63f8909
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
6d19b73
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
1416a23
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
14ccb53
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
bf30d9a
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
3a3e409
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
2d666bc
[2.0.0-SNAPSHOT]
GoodforGodMay 14, 2023
f09f38a
[2.0.0]
GoodforGodMay 14, 2023
d1ec9e5
[2.0.0]
GoodforGodMay 14, 2023
b05bd8a
[2.0.0]
GoodforGodMay 15, 2023
e6bee19
[2.0.0]
GoodforGodMay 15, 2023
c64a301
[2.0.0]
GoodforGodMay 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion.editorconfig
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,30 @@ root = true
end_of_line = lf
charset = utf-8

# Json
[*.json]
indent_size = 2
indent_style = space
insert_final_newline = false
trim_trailing_whitespace = true

# Yaml
[{*.yml, *.yaml}]
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

# Property files
[*.properties]
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true


# XML files
[*.xml]
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
35 changes: 27 additions & 8 deletions.gitattributes
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@
# and leave all files detected as binary untouched.
* text=auto

#

# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.bash text eol=lf
*.css text diff=css
Expand All@@ -26,16 +25,36 @@
*.xml text
*.yml text eol=lf


# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
# Archives
*.7z binary
*.br binary
*.gz binary
*.tar binary
*.zip binary
*.jar binary
*.so binary
*.war binary
*.dll binary
*.ear binary
*.gif binary

# Documents
*.pdf binary

# Images
*.ico binary
*.jar binary
*.gif binary
*.jpg binary
*.jpeg binary
*.png binary
*.so binary
*.war binary
*.psd binary
*.webp binary

# Fonts
*.woff2 binary

# Other
*.exe binary
*.class binary
*.ear binary
12 changes: 10 additions & 2 deletions.github/workflows/gradle.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '11' ]
java: [ '11', '17' ]
name: Java ${{ matrix.java }} setup

steps:
Expand All@@ -32,11 +32,19 @@ jobs:
run: ./gradlew spotlessCheck

- name: Test
if: matrix.java == '11'
run: ./gradlew test jacocoTestReport
env:
API_KEY: ${{ secrets.API_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY_1 }}

- name: Test
if: matrix.java == '17'
run: ./gradlew test jacocoTestReport
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY_2 }}

- name: SonarQube
if: matrix.java == '17'
run: ./gradlew sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
21 changes: 16 additions & 5 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
/.settings/
.idea
.idea/httpRequests
*.iml
### Package Files
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

### Gradle template
.gradle
build
build/
target/

### Idea generated files
.idea
.settings/
*.iml
out/
131 changes: 64 additions & 67 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
# Java EtherScan API

[![Minimum required Java version](https://img.shields.io/badge/Java-1.8%2B-blue?logo=openjdk)](https://openjdk.org/projects/jdk8/)
[![GitHub Action](https://github.com/goodforgod/java-etherscan-api/workflows/Java%20CI/badge.svg)](https://github.com/GoodforGod/java-etherscan-api/actions?query=workflow%3A%22Java+CI%22)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=GoodforGod_java-etherscan-api&metric=coverage)](https://sonarcloud.io/dashboard?id=GoodforGod_java-etherscan-api)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=GoodforGod_java-etherscan-api&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=GoodforGod_java-etherscan-api)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=GoodforGod_java-etherscan-api&metric=ncloc)](https://sonarcloud.io/dashboard?id=GoodforGod_java-etherscan-api)
[![](https://jitpack.io/v/GoodforGod/java-etherscan-api.svg)](https://jitpack.io/#GoodforGod/java-etherscan-api)

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

Library supportsall availableEtherScan *API* calls for all available *Ethereum Networks* for *etherscan.io*
Library supports EtherScan *API* for all available *Ethereum Networks* for *etherscan.io*

## Dependency :rocket:

**Gradle**
```groovy
dependencies {
compile "com.github.goodforgod:java-etherscan-api:1.2.1"
}
implementation "com.github.goodforgod:java-etherscan-api:2.0.0"
```

**Maven**
```xml
<dependency>
<groupId>com.github.goodforgod</groupId>
<artifactId>java-etherscan-api</artifactId>
<version>1.2.1</version>
<version>2.0.0</version>
</dependency>
```

Expand All@@ -42,143 +40,142 @@ dependencies {
- [Token](#token-api)
- [Version History](#version-history)

## Mainnet and Testnets
## MainNet and TestNets

API support all Ethereum [default networks](https://docs.etherscan.io/getting-started/endpoint-urls):
- [Mainnet](https://api.etherscan.io/)
- [Goerli](https://api-goerli.etherscan.io/)
- [Sepolia](https://api-sepolia.etherscan.io/)

API support Ethereum: *[MAINNET](https://etherscan.io),
[ROPSTEN](https://ropsten.etherscan.io),
[KOVAN](https://kovan.etherscan.io),
[RINKEBY](https://rinkeby.etherscan.io),
[GORLI](https://goerli.etherscan.io),
[TOBALABA](https://tobalaba.etherscan.com)* networks.
```java
EtherScanApi api = new EtherScanApi(EthNetwork.MAINNET); // Default
EtherScanApi apiRinkeby = new EtherScanApi(EthNetwork.RINKEBY);
EtherScanApi apiRopsten = new EtherScanApi(EthNetwork.ROPSTEN);
EtherScanApi apiKovan = new EtherScanApi("YourApiKey", EthNetwork.KOVAN);
EtherScanAPI api = EtherScanAPI.build();
EtherScanAPI apiGoerli = EtherScanAPI.builder().withNetwork(EthNetworks.GORLI).build();
EtherScanAPI apiSepolia = EtherScanAPI.builder().withNetwork(EthNetworks.SEPOLIA).build();
```

### Custom Network

In case you want to use API for other EtherScan compatible network, you can easily provide custom network with domain api URI.

```java
EtherScanAPI api = EtherScanAPI.builder()
.withNetwork(() -> URI.create("https://api-my-custom.etherscan.io/api"))
.build();
```

## Custom HttpClient

In case you need to set custom timeout, custom headers or better implementation for HttpClient,
just implement **IHttpExecutor** by your self or initialize it with your values.
just implement **EthHttpClient** by your self or initialize it with your values.

```java
int connectionTimeout = 10000;
int readTimeout = 7000;

Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(connectionTimeout);
Supplier<IHttpExecutor> supplierFull = () -> new HttpExecutor(connectionTimeout, readTimeout);

EtherScanApi api = new EtherScanApi(EthNetwork.RINKEBY, supplier);
EtherScanApi apiWithKey = new EtherScanApi("YourApiKey", EthNetwork.MAINNET, supplierFull);
Supplier<EthHttpClient> ethHttpClientSupplier = () -> new UrlEthHttpClient(Duration.ofMillis(300), Duration.ofMillis(300));
EtherScanAPI api = EtherScanAPI.builder()
.withHttpClient(supplier)
.build();
```

## API Examples

You can read about all API methods on [Etherscan](https://etherscan.io/apis)
You can read about all API methods on [Etherscan](https://docs.etherscan.io/api-endpoints/accounts)

*Library support all available EtherScan API.*

You can use library *with or without* API key *([Check API request\sec restrictions when used without API key](https://ethereum.stackexchange.com/questions/34190/does-etherscan-require-the-use-of-an-api-key))*.
You can use library *with or without* API key *([Check API request\sec restrictions when used without API key](https://docs.etherscan.io/getting-started/viewing-api-usage-statistics))*.

Library will automatically limit requests up to **5 req/sec** when used *without* key.
Library will automatically limit requests up to **1 requests in 5 seconds** when used *without* key and up to **5 requests in 1 seconds** when used with API KEY (free plan).
```java
EtherScanApi api = new EtherScanApi();
EtherScanApi api = new EtherScanApi("YourApiKey");
EtherScanAPI.builder()
.withApiKey(ApiRunner.API_KEY)
.build();
```

Below are examples for each API category.

### AccountApi
### AccountAPI

**Get Ether Balance for a single Address**

```java
EtherScanApi api =new EtherScanApi();
EtherScanAPI api =EtherScanAPI.build();
Balance balance = api.account().balance("0x8d4426f94e42f721C7116E81d6688cd935cB3b4F");
```

### BlockApi
### BlockAPI

**Get uncles block for block height**

```java
EtherScanApi api =new EtherScanApi();
EtherScanAPI api =EtherScanAPI.build();
Optional<UncleBlock> uncles = api.block().uncles(200000);
```

### ContractApi
### ContractAPI
**Request contract ABI from [verified codes](https://etherscan.io/contractsVerified)**
```java
EtherScanApi api =new EtherScanApi();
EtherScanAPI api =EtherScanAPI.build();
Abi abi = api.contract().contractAbi("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413");
```

### LogsApi
### LogsAPI

**Get event logs for single topic**

```java
EtherScanApi api =new EtherScanApi();
LogQuery query =LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
EtherScanAPI api =EtherScanAPI.build();
LogQuery query =LogQuery.builder("0x33990122638b9132ca29c723bdf037f1a891a70c")
.withTopic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
.build();
List<Log> logs = api.logs().logs(query);
```

**Get event logs for 3 topics with respectful operations**

```java
EtherScanApi api = new EtherScanApi();
LogQuery query = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c", 379224, 400000)
.topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
EtherScanAPI api = EtherScanAPI.build();
LogQuery query = LogQuery.builder("0x33990122638b9132ca29c723bdf037f1a891a70c")
.withBlockFrom(379224)
.withBlockTo(400000)
.withTopic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545",
"0x72657075746174696f6e00000000000000000000000000000000000000000000",
"0x72657075746174696f6e00000000000000000000000000000000000000000000")
.setOpTopic0_1(LogOp.AND)
.setOpTopic0_2(LogOp.OR)
.setOpTopic0_2(null)
.setOpTopic1_2(LogOp.AND)
.build();

List<Log> logs = api.logs().logs(query);
```

### Proxy Api

**Get tx detailds with proxy endpoint**
### Proxy API

**Get tx details with proxy endpoint**
```java
EtherScanApi api =new EtherScanApi(EthNetwork.MAINNET);
EtherScanAPI api =EtherScanAPI.build();
Optional<TxProxy> tx = api.proxy().tx("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
```

**Get block info with proxy endpoint**

```java
EtherScanApi api =new EtherScanApi(EthNetwork.MAINNET);
EtherScanAPI api =EtherScanAPI.build();
Optional<BlockProxy> block = api.proxy().block(15215);
```

### StatsApi
### StatsAPI

**Statistic about last price**

```java
EtherScanApi api =new EtherScanApi();
Price price = api.stats().lastPrice();
EtherScanAPI api =EtherScanAPI.build();
Price price = api.stats().priceLast();
```

### TransactionApi
### TransactionAPI

**Request receipt status for tx**

```java
EtherScanApi api =new EtherScanApi();
EtherScanAPI api =EtherScanAPI.build();
Optional<Boolean> status = api.txs().receiptStatus("0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76");
```

### TokenApi
### TokenAPI

You can read about token API [here](https://etherscan.io/apis#tokens)
You can read about token API [here](https://docs.etherscan.io/api-endpoints/tokens)

Token API methods migrated to [Account](#account-api) & [Stats](#stats-api) respectfully.

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp