Installation
How to install and set up zksync2-java for your project.
About zksync2-java
The zksync2-java library builds upon the web3j library, ensuring that developers familiar with Web3j can easily
transition to using ZKsync-specific features. It supports all the standard Web3j functionalities while adding
additional methods tailored to ZKsync chains.
ZKsync-specific methods
The library includes a variety of methods specific to ZKsync, such as:
- Estimating fees for transactions (
estimateFee). - Calculating gas usage for transactions (
estimateGas,estimateGasL1). - Retrieving account balances and block details.
- Managing transactions between Layer 1 (L1) and Layer 2 (L2).
- Accessing bridge contracts and batch details.
Prerequisites
Before beginning the installation, make sure you have:
- Java Development Kit (JDK): Java 8 or higher installed on your machine.
- Maven or Gradle: Depending on your project's build system, ensure Maven or Gradle is set up correctly.
Check out the Java installation guide for more information.
Installation steps
Maven setup
For projects using Maven, add the following dependency block to your pom.xml file to include the zksync2-java SDK:
<project>
...
<dependencies>
<dependency>
<groupId>io.zksync</groupId>
<artifactId>zksync2</artifactId>
<version>v0.2.0</version>
</dependency>
</dependencies>
</project>
Gradle setup
For projects utilizing Gradle, add the dependency to your build.gradle file as follows:
dependencies {
implementation "io.zksync:zksync2:v0.2.0"
}