This project contains Ethereum 2.0 related modules.
At the moment it only contains the Beacon Node API client.
Web3j client library for the Eth2 Beacon Node API.
- JAX-RS 2.1 (Java RESTful Web Services)
- Jackson Annotations 2.11
- Jersey Client 2.32
You can add the library to your project using either Gradle or Maven.
<dependency>
<groupId>org.web3j.eth2</groupId>
<artifactId>beacon-node-api</artifactId>
<version>1.0.0</version>
</dependency>
implementation 'org.web3j.eth2:beacon-node-api:1.0.0'
Create a service pointing to your Beacon Chain node:
var service = new BeaconNodeService("http://public-mainnet-node.ethereum.org/api");
Build a client instance using the client factory:
var client = BeaconNodeClientFactory.build(service);
That's it! You can start using the client to call the node endpoints, for instance:
client.getBeacon().getBlocks().findById(NamedBlockId.HEAD);
Run this command on a console:
./gradlew build
This library is tested against different Beacon Node API nodes to ensure that it works on all of them. At the moment the tests run against Lighthouse and Teku.
Other Beacon Node implementations providing Docker images such as Nimbus and Prysm will be included in the future.
To run the integration tests, you'll need Docker running. Unless you pull the images manually, you will also need to define these variables in order to pull the Docker images from the Docker Hub registry:
registry.username
registry.password
Check the Docker client API for more information on configuration options.
Run this command on a console:
./gradlew integrationTest