Framework agnostic modular Java 17+ integration library for Ethereum blockchains
- Latest Stable Version: 0.13.0
- Latest Snapshot Version: 0.14.0-SNAPSHOT
Structure of dependencies between modules:
etherjar-abietherjar-domainetherjar-hex
etherjar-domainetherjar-hexetherjar-rlpetherjar-rpc-jsonetherjar-domainetherjar-hex
etherjar-rpc-apietherjar-rpc-jsonetherjar-domainetherjar-hex
etherjar-rpc-emeraldetherjar-rpc-api
etherjar-rpc-kotlinetherjar-rpc-apietherjar-rpc-json
etherjar-rpc-emerald-kotlinetherjar-rpc-apietherjar-rpc-kotlin
etherjar-rpc-http-ktoretherjar-rpc-apietherjar-rpc-jsonetherjar-rpc-kotlin
etherjar-rpc-httpetherjar-rpc-apietherjar-domainetherjar-hex
etherjar-rpc-wsetherjar-rpc-api
etherjar-solidityetherjar-abietherjar-domain
etherjar-txetherjar-rlpetherjar-domain
etherjar-contractetherjar-abietherjar-domainetherjar-rpc-api
etherjar-erc20etherjar-abietherjar-domainetherjar-contract
where
etherjar-abi- Smart contract Application Binary Interface (ABI)etherjar-contract- Methods to organize contract calletherjar-domain- Core module contains pure domain logic (Address,Block,Transaction,Weiand so on)etherjar-erc20- Classes to simplify use of ERC-20 tokensetherjar-hex- Hexadecimal encoding and encoding utils forString,BigInteger, byte arraysetherjar-rlp- Reading and writing RLP (Recursive Length Prefix) encoded dataetherjar-rpc-json- JSON mapping to/from Java objectsetherjar-rpc-api- JSON-RPC API generic implementationetherjar-rpc-kotlin- Kotlin coroutines client for JSON-RPC API data-layeretherjar-rpc-http-ktor- Ktor based Kotlin coroutines transport for JSON-RPC API data-layeretherjar-rpc-emerald- gRPC transport, see Emerald Dshackleetherjar-rpc-emerald-kotlin- Kotlin coroutines gRPC transport for Emerald APIetherjar-rpc-http- HTTP transport implementation for JSON-RPC API data-layeretherjar-rpc-ws- WebSocket transport to subscribe to new blocksetherjar-solidity- Thin wrapper aroundsolcSolidity compileretherjar-tx- Read, verify and manipulate Transactions
<repositories>
<repository>
<id>etherjar</id>
<url>https://maven.emrld.io</url>
</repository>
</repositories>
<dependency>
<groupId>io.emeraldpay.etherjar</groupId>
<artifactId>etherjar-rpc-http</artifactId>
<version>0.12.0</version>
</dependency>repositories {
maven {
url "https://maven.emrld.io"
}
}
dependencies {
implementation "io.emeraldpay.etherjar:etherjar-rpc-http:0.12.0"
}How to call web3_clientVersion low-level JSON-RPC API method:
public class GetClientVersion {
public static void main(String[] args)
throws URISyntaxException, IOException, ExecutionException, InterruptedException {
try (RpcTransport transport = HttpRpcTransport.newBuilder().connectTo("http://127.0.0.1:8545").build()) {
RpcClient client = new DefaultRpcClient(transport);
Future<String> req = client.execute(Commands.web3().clientVersion());
System.out.println(String.format("Client version: %s", req.get()));
}
}
}How to call eth_gasPrice low-level JSON-RPC API method:
public class GetGasPrice {
public static void main(String[] args)
throws URISyntaxException, IOException, ExecutionException, InterruptedException {
try (RpcTransport transport = HttpRpcTransport.newBuilder().connectTo("http://127.0.0.1:8545").build()) {
RpcClient client = new DefaultRpcClient(transport);
Future<Wei> req = client.execute(Commands.eth().getGasPrice());
System.out.println(String.format("Gas Price: %s Ether", req.get().toEthers(12)));
}
}
}For bugs, questions and discussions please use the GitHub Issues.
Copyright 2021 EmeraldPay, Inc
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.