npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@leemina/burn-chain

v1.0.0

Published

![downloads](https://img.shields.io/github/downloads/atom/atom/total.svg) ![build](https://img.shields.io/appveyor/ci/:user/:repo.svg) ![chat](https://img.shields.io/discord/:serverId.svg)

Downloads

3

Readme

🚀 zksync2-java Java SDK 🚀

downloads build chat

Era Logo

In order to provide easy access to all the features of zkSync Era, the zksync2-java Java SDK was created, which is made in a way that has an interface very similar to those of web3j. In fact, web3j is a peer dependency of our library and most of the objects exported by zksync2-java inherit from the corresponding web3j objects and override only the fields that need to be changed.

While most of the existing SDKs functionalities should work out of the box, deploying smart contracts or using unique zkSync features, like account abstraction, requires providing additional fields to those that Ethereum transactions have by default.

The library is made in such a way that after replacing web3j with zksync2-java most client apps will work out of box.

🔗 For a detailed walkthrough, refer to the official documentation.

Dependency

For connecting ZkSync2 library just add the following dependency to your build file.

Maven pom.xml

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>io.zksync</groupId>
      <artifactId>zksync2</artifactId>
      <version>v0.2.0</version>
    </dependency>
  </dependencies>
</project>

Gradle build.gradle

dependencies {
    implementation "io.zksync:zksync2:v0.2.0"
}

📝 Examples

The complete examples with various use cases are available here.

Connect to the zkSync Era network:

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"));
    }
}

Create a wallet

import com.sun.net.httpserver.HttpServer;
import io.zksync.crypto.signer.EthSigner;
import io.zksync.protocol.ZkSync;
import io.zksync.protocol.core.Token;
import io.zksync.protocol.account.wallet;

public class Main {
    public static void main(String... args) {
        ZkSync zksync = ZkSync.build(new HttpService("https://sepolia.era.zksync.dev"));
        Credentials credentials = Credentials.create("PRIVATE_KEY");
        Web3j l1Web3 = Web3j.build(new HttpService("https://rpc.ankr.com/eth_sepolia"));

        Wallet wallet = new Wallet(l1Web3, zksync, credentials);
    }
}

Check account balances

BigInteger ethBalance = wallet.getBalance().send(); // balance on zkSync Era network

BigInteger ethBalanceL1 = wallet.getBalanceL1().send(); // balance on Sepolia network

Transfer funds

Transfer funds among accounts on L2 network.

TransferTransaction transaction = new TransferTransaction("RECEIVER", amount, signer.getAddress());
TransactionReceipt receipt = testWallet.transfer(transaction).sendAsync().join();

Deposit funds

Transfer funds from L1 to L2 network.

DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, amount);
String hash = testWallet.deposit(transaction).sendAsync().join().getResult();

Withdraw funds

Transfer funds from L2 to L1 network.

WithdrawTransaction transaction = new WithdrawTransaction(ZkSyncAddresses.ETH_ADDRESS, amount, testWallet.getAddress());
TransactionReceipt result = testWallet.withdraw(transaction).sendAsync().join();

🤖 Running tests

In order to run test you need to run local-setup on your machine. For running tests, use:

gradle clean test

🤝 Contributing

We welcome contributions from the community! If you're interested in contributing to the zksync2-java Java SDK, please take a look at our CONTRIBUTING.md for guidelines and details on the process.

Thank you for making zksync2-java Java SDK better! 🙌