-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: refactor the Java SDK * fix: remove redundancy * fix: missing content * fix: update links * fix: minor update
- Loading branch information
1 parent
d9e2aae
commit 383b1de
Showing
20 changed files
with
297 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ython/02.api/00.providers/01.providers.md → ...python/02.api/00.providers/01.provider.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Overview | ||
description: An introduction to zksync2-java and its features. | ||
tags: ["zksync", "java", "sdk", "blockchain", "ethereum"] | ||
--- | ||
|
||
The `zksync2-java` is a powerful tool designed for developers working with the Ethereum blockchain. | ||
|
||
## What is `zksync2-java`? | ||
|
||
The `zksync2-java` library is a Java SDK designed to facilitate interactions with the ZkSync Era network. It provides a | ||
set of tools and methods that allow developers to: | ||
|
||
- Connect to the ZkSync network using a Web3 provider. | ||
- Estimate transaction fees and gas usage. | ||
- Interact with smart contracts deployed on ZkSync. | ||
- Retrieve detailed information about transactions, blocks, and accounts. | ||
- Utilize ZkSync-specific functionalities such as L1 to L2 transactions, bridge contracts, and more. | ||
|
||
## Key features | ||
|
||
### Seamless integration with web3j | ||
|
||
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 the ZkSync Era. | ||
|
||
### 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. | ||
|
||
### Ease of use | ||
|
||
The `zksync2-java` library is designed with simplicity in mind, offering straightforward APIs and | ||
documentation to help developers get started quickly and efficiently. | ||
|
||
::callout{icon="i-heroicons-light-bulb"} | ||
To get started with Java, follow the [installation instructions](/sdk/java/introduction/installation) provided. | ||
:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: Why zksync2-java | ||
description: Benefits and Advantages of zksync2-java | ||
tags: ["zksync", "java", "ethereum", "layer-2", "zero-knowledge rollups"] | ||
--- | ||
|
||
Choosing the Java SDK for ZKSync opens up a plethora of opportunities for businesses and developers eager to explore | ||
the next generation of blockchain applications. | ||
|
||
Here are key reasons why `zksync2-java` is a valuable addition to your development toolkit: | ||
|
||
### Seamless web3 integration | ||
|
||
- **Built on web3j**: The library extends `web3j`, making it easy for developers familiar with Web3j to start using | ||
ZkSync-specific features without a steep learning curve. | ||
- **Standard and extended functionality**: It supports all standard Web3j functionalities while adding methods unique | ||
to ZkSync Era, enabling more versatile blockchain interactions. | ||
|
||
### ZkSync-specific enhancements | ||
|
||
- **Layer 2 transactions**: Leverage the power of zk-rollups for low-cost, high-throughput transactions. | ||
- **Advanced fee and gas estimation**: Precisely estimate transaction fees and gas usage with methods | ||
like `estimateFee`, `estimateGas`, and `estimateGasL1`. | ||
- **Comprehensive account and block management**: Retrieve detailed information about accounts, blocks, and | ||
transactions on the ZkSync network. | ||
- **Bridge contract access**: Easily interact with ZkSync Era bridge contracts for L1 to L2 operations. | ||
|
||
### User-friendly design | ||
|
||
- **Easy initialization**: Quickly set up your provider with minimal configuration. | ||
- **Clear and concise API**: The library's API is designed for simplicity and ease of use, ensuring you can integrate | ||
it into your projects with minimal effort. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: Installation | ||
description: How to install and set up zksync2-java for your project. | ||
tags: ["zksync", "java", "sdk installation"] | ||
--- | ||
|
||
Integrating the `zksync2-java` into your Java project equips you with the tools necessary to interact with the | ||
ZKSync Layer-2 blockchain solution efficiently. | ||
|
||
## 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. | ||
|
||
::callout{icon="i-heroicons-light-bulb"} | ||
Check out the [Java installation guide](https://www.java.com/en/download) 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: | ||
|
||
```xml | ||
<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: | ||
|
||
```groovy | ||
dependencies { | ||
implementation "io.zksync:zksync2:v0.2.0" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: Getting Started | ||
description: Getting started with zksync2-java | ||
tag: ["zksync", "java", "blockchain development", "layer-2", "zero-knowledge rollups"] | ||
--- | ||
|
||
This guide is designed to help you quickly get up and running with the SDK, enabling you to interact with the ZKSync | ||
Era blockchain efficiently. | ||
|
||
## Understanding key components | ||
|
||
Before delving into code examples, it's useful to familiarize yourself with the primary objects provided by the SDK and | ||
their responsibilities: | ||
|
||
- **`ZkSync`**: This class provides the connection to the ZKSync Era blockchain. It allows you to query blockchain | ||
states, such as account details, block or transaction information, and event logs. It also facilitates read-only | ||
interactions with the blockchain through calls and enables writing to the blockchain by sending transactions. | ||
- **`Wallet`**: This object encapsulates all operations that interact with a user account. It manages the account's | ||
private key, which is used to sign various types of payloads, and offers straightforward methods for executing common | ||
blockchain functions. | ||
|
||
::callout{icon="i-heroicons-light-bulb"} | ||
Ensure you have installed the `zksync2-java` SDK. If you still need to do so, please refer to | ||
the [installation guide](/sdk/java/introduction/installation) for detailed instructions. | ||
:: | ||
|
||
## Examples | ||
|
||
Connect to the ZKsync Era network: | ||
|
||
```java | ||
import io.zksync.protocol.ZkSync; | ||
import org.web3j.protocol.http.HttpService; | ||
|
||
public class Main { | ||
public static void main(String ...args) { | ||
ZkSync zksync = ZkSync.build(new HttpService("http://127.0.0.1:3050")); | ||
} | ||
} | ||
``` | ||
|
||
Get the latest block number: | ||
|
||
```java | ||
BigInteger blockNumber = zksync.ethBlockNumber().send().getBlockNumber(); | ||
; | ||
``` | ||
|
||
```java | ||
ZksBlock block = zksync.zksGetBlockByHash("0xb472c070c9e121ba42702f6c322b7b266e287a4d8b5fa426ed265b105430c397", true).send().getBlock(); | ||
``` | ||
|
||
```java | ||
ZkTransaction transaction = zksync.zksGetTransactionByHash("0x9af27afed9a4dd018c0625ea1368afb8ba08e4cfb69b3e76dfb8521c8a87ecfc").send().getResult(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
content/sdk/40.java/02.api/00.providers/00.introduction.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: Introduction | ||
description: Overview of Web3Providers and their functions. | ||
tags: ["web3", "blockchain", "provider", "zksync"] | ||
--- | ||
|
||
A Web3 Provider object provides application-layer access to underlying blockchain networks. It serves as a crucial | ||
interface for interacting with various blockchain functionalities, enabling developers to connect, communicate, and | ||
perform operations on the blockchain. | ||
|
||
The [`zksync2-java`](https://github.com/zksync-sdk/zksync2-java) library supports provider methods from | ||
the [`web3j`](https://docs.web3j.io/4.9.7/) library and supplies additional functionality tailored for the ZKsync Era network. | ||
|
||
### Key features | ||
|
||
- **Network connectivity:** Establishes connections to blockchain networks, allowing applications to interact with them. | ||
- **Transaction management:** Facilitates the creation, sending, and tracking of transactions. | ||
- **Gas estimation:** Provides estimations for the amount of gas required for transactions. | ||
- **Account management:** Retrieves balances and transaction histories for accounts. | ||
- **Contract interaction:** Enables interaction with smart contracts, including deploying and calling contract methods. |
Oops, something went wrong.