https://github.com/matter-labs/zksync-js
ZKsync OS JavaScript SDK
https://github.com/matter-labs/zksync-js
zksync
Last synced: 2 months ago
JSON representation
ZKsync OS JavaScript SDK
- Host: GitHub
- URL: https://github.com/matter-labs/zksync-js
- Owner: matter-labs
- License: mit
- Created: 2025-11-12T15:34:32.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-02-12T22:17:17.000Z (2 months ago)
- Last Synced: 2026-02-13T03:35:34.091Z (2 months ago)
- Topics: zksync
- Language: TypeScript
- Homepage: https://matter-labs.github.io/zksync-js/latest/
- Size: 2.26 MB
- Stars: 3
- Watchers: 0
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS.md
- Security: .github/SECURITY.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
# ⚡️ zksync-js ⚡️
_TypeScript SDK for deposits, withdrawals, and RPC access across the Elastic Network_
[](https://github.com/matter-labs/zksync-js/actions/workflows/ci-check.yaml)
[](https://github.com/matter-labs/zksync-js/releases/latest)
[](LICENSE)
[](https://x.com/zksync)
[](https://matter-labs.github.io/zksync-js/latest/)
Quickstart ·
User Book ·
Contributing
## ✨ Features
- **Adapters for both worlds** – choose [`viem`](https://viem.sh) or [`ethers`](https://docs.ethers.io)
- **Deposits (L1 → L2)** – ETH and ERC-20 transfers
- **Withdrawals (L2 → L1)** – full two-step flows with status tracking + finalization
- **zks\_ RPC methods** – typed helpers for logProofs, receipts, and bridgehub access
- **Helper methods** – helpers for l1-l2 token address mapping, contract address fetching
- **Try-methods** – no-throw style (`tryCreate`, `tryWait`) for UI / services
## 📦 Installation
Install the adapter you need:
viem adapter
```bash
npm install @matterlabs/zksync-js viem
```
ethers adapter
```bash
npm install @matterlabs/zksync-js ethers
```
## ⚡️ Quick-start
For exhaustive examples please refer to [`./examples`](./examples/) directory.
**ETH deposit (ethers)**
```ts
import { JsonRpcProvider, Wallet, parseEther } from 'ethers';
import { createEthersClient, createEthersSdk } from '@matterlabs/zksync-js/ethers';
import { ETH_ADDRESS } from '@matterlabs/zksync-js/core';
const l1Provider = new JsonRpcProvider('https://sepolia.infura.io/v3/...');
const l2Provider = new JsonRpcProvider('https://zksync-testnet.rpc');
const signer = new Wallet(process.env.PRIVATE_KEY!, l1Provider);
const client = await createEthersClient({ l1Provider, l2Provider, signer });
const sdk = createEthersSdk(client);
const deposit = await sdk.deposits.create({
token: ETH_ADDRESS,
amount: parseEther('0.01'),
to: signer.address,
});
await sdk.deposits.wait(handle, { for: 'l2' });
console.log('Deposit complete ✅');
```
**ETH deposit (viem)**
```ts
import { createPublicClient, createWalletClient, http, parseEther } from 'viem';
import { createViemClient, createViemSdk } from '@matterlabs/zksync-js/viem';
import { ETH_ADDRESS } from '@matterlabs/zksync-js/core';
const l1 = createPublicClient({ transport: http('https://sepolia.infura.io/v3/...') });
const l2 = createPublicClient({ transport: http('https://zksync-testnet.rpc') });
const l1Wallet = createWalletClient({
account,
transport: http('https://sepolia.infura.io/v3/...'),
});
const client = createViemClient({ l1, l2, l1Wallet });
const sdk = createViemSdk(client);
const handle = await sdk.deposits.create({
token: ETH_ADDRESS,
amount: parseEther('0.01'),
to: account.address,
});
await sdk.deposits.wait(handle, { for: 'l2' });
console.log('Deposit complete ✅');
```
> See [Quickstart docs](https://matter-labs.github.io/zksync-js/latest/quickstart/index.html) for full examples.
## 📚 Documentation
- [User Book](https://matter-labs.github.io/zksync-js/latest/) – guides, concepts, API docs
- [How-to Guides](https://matter-labs.github.io/zksync-js/latest/guides/index.html) – deposits, withdrawals, RPC helpers
- [Mental Model](https://matter-labs.github.io/zksync-js/latest/overview/mental-model.html) – mental model, status vs wait, finalization
## 🤝 Contributing
Bug reports, fixes, and new features are welcome! Please read the [contributing guide](.github/CONTRIBUTING.md) to get started.
## 📜 License
This project is licensed under the terms of the **MIT License** – see the [LICENSE](LICENSE) file for details.