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

🔗 Polished Java library for EtherScan.io API

License

NotificationsYou must be signed in to change notification settings

GoodforGod/java-etherscan-api

Repository files navigation

GitHub ActionCoverageMaintainability RatingLines of Code

Etherscan.io Java API implementation.

Library supports all available EtherScanAPI calls for all availableEthereum Networks foretherscan.io

Dependency 🚀

Gradle

dependencies {    compile"com.github.goodforgod:java-etherscan-api:1.1.1"}

Maven

<dependency>    <groupId>com.github.goodforgod</groupId>    <artifactId>java-etherscan-api</artifactId>    <version>1.1.1</version></dependency>

Content

Mainnet and Testnets

API support Ethereum:MAINNET,ROPSTEN,KOVAN,RINKEBY,GORLI,TOBALABA networks.

EtherScanApiapi =newEtherScanApi(EthNetwork.MAINNET);// DefaultEtherScanApiapiRinkeby =newEtherScanApi(EthNetwork.RINKEBY);EtherScanApiapiRopsten =newEtherScanApi(EthNetwork.ROPSTEN);EtherScanApiapiKovan =newEtherScanApi("YourApiKey",EthNetwork.KOVAN);

Custom HttpClient

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

intconnectionTimeout =10000;intreadTimeout =7000;Supplier<IHttpExecutor>supplier = () ->newHttpExecutor(connectionTimeout);Supplier<IHttpExecutor>supplierFull = () ->newHttpExecutor(connectionTimeout,readTimeout);EtherScanApiapi =newEtherScanApi(EthNetwork.RINKEBY,supplier);EtherScanApiapiWithKey =newEtherScanApi("YourApiKey",EthNetwork.MAINNET,supplierFull);

API Examples

You can read about all API methods onEtherscan

Library support all available EtherScan API.

You can use librarywith or without API key(Check API request\sec restrictions when used without API key).

Library will automatically limit requests up to5 req/sec when usedwithout key.

EtherScanApiapi =newEtherScanApi();EtherScanApiapi =newEtherScanApi("YourApiKey");

Below are examples for each API category.

Account Api

Get Ether Balance for a single Address

EtherScanApiapi =newEtherScanApi();Balancebalance =api.account().balance("0x8d4426f94e42f721C7116E81d6688cd935cB3b4F");

Block Api

Get uncles block for block height

EtherScanApiapi =newEtherScanApi();Optional<UncleBlock>uncles =api.block().uncles(200000);

Contract Api

Request contract ABI fromverified codes

EtherScanApiapi =newEtherScanApi();Abiabi =api.contract().contractAbi("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413");

Logs Api

Get event logs for single topic

EtherScanApiapi =newEtherScanApi();LogQueryquery =LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")           .topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")           .build();List<Log>logs =api.logs().logs(query);

Get event logs for 3 topics with respectful operations

EtherScanApiapi =newEtherScanApi();LogQueryquery =LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c",379224,400000)        .topic("0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545","0x72657075746174696f6e00000000000000000000000000000000000000000000","0x72657075746174696f6e00000000000000000000000000000000000000000000")        .setOpTopic0_1(LogOp.AND)        .setOpTopic0_2(LogOp.OR)        .setOpTopic1_2(LogOp.AND)        .build();List<Log>logs =api.logs().logs(query);

Proxy Api

Get tx detailds with proxy endpoint

EtherScanApiapi =newEtherScanApi(EthNetwork.MAINNET);Optional<TxProxy>tx =api.proxy().tx("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");

Get block info with proxy endpoint

EtherScanApiapi =newEtherScanApi(EthNetwork.MAINNET);Optional<BlockProxy>block =api.proxy().block(15215);

Stats Api

Statistic about last price

EtherScanApiapi =newEtherScanApi();Priceprice =api.stats().lastPrice();

Transaction Api

Request receipt status for tx

EtherScanApiapi =newEtherScanApi();Optional<Boolean>status =api.txs().receiptStatus("0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76");

Token Api

You can read about token APIhere

Token API methods migrated toAccount &Stats respectfully.

License

This project licensed under the MIT - see theLICENSE file for details.

About

🔗 Polished Java library for EtherScan.io API

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors6

Languages


[8]ページ先頭

©2009-2025 Movatter.jp