@matterlabs/zksync-js 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/adapters/ethers/client.cjs +4548 -0
- package/dist/adapters/ethers/client.cjs.map +1 -0
- package/dist/adapters/ethers/client.d.ts +61 -0
- package/dist/adapters/ethers/client.js +5 -0
- package/dist/adapters/ethers/errors/error-ops.d.ts +20 -0
- package/dist/adapters/ethers/errors/revert.d.ts +28 -0
- package/dist/adapters/ethers/index.cjs +7537 -0
- package/dist/adapters/ethers/index.cjs.map +1 -0
- package/dist/adapters/ethers/index.d.ts +12 -0
- package/dist/adapters/ethers/index.js +8 -0
- package/dist/adapters/ethers/resources/deposits/context.d.ts +27 -0
- package/dist/adapters/ethers/resources/deposits/index.d.ts +46 -0
- package/dist/adapters/ethers/resources/deposits/routes/erc20-base.d.ts +2 -0
- package/dist/adapters/ethers/resources/deposits/routes/erc20-nonbase.d.ts +2 -0
- package/dist/adapters/ethers/resources/deposits/routes/eth-nonbase.d.ts +2 -0
- package/dist/adapters/ethers/resources/deposits/routes/eth.d.ts +2 -0
- package/dist/adapters/ethers/resources/deposits/routes/types.d.ts +10 -0
- package/dist/adapters/ethers/resources/deposits/services/verification.d.ts +9 -0
- package/dist/adapters/ethers/resources/token-info.d.ts +31 -0
- package/dist/adapters/ethers/resources/utils.d.ts +39 -0
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +19 -0
- package/dist/adapters/ethers/resources/withdrawals/index.d.ts +56 -0
- package/dist/adapters/ethers/resources/withdrawals/routes/erc20-nonbase.d.ts +2 -0
- package/dist/adapters/ethers/resources/withdrawals/routes/eth-nonbase.d.ts +2 -0
- package/dist/adapters/ethers/resources/withdrawals/routes/eth.d.ts +2 -0
- package/dist/adapters/ethers/resources/withdrawals/routes/types.d.ts +18 -0
- package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +33 -0
- package/dist/adapters/ethers/rpc.d.ts +4 -0
- package/dist/adapters/ethers/sdk.cjs +6245 -0
- package/dist/adapters/ethers/sdk.cjs.map +1 -0
- package/dist/adapters/ethers/sdk.d.ts +29 -0
- package/dist/adapters/ethers/sdk.js +6 -0
- package/dist/adapters/ethers/typechain/IAssetRouterBase.d.ts +198 -0
- package/dist/adapters/ethers/typechain/IBridgehub.d.ts +731 -0
- package/dist/adapters/ethers/typechain/IERC20.d.ts +108 -0
- package/dist/adapters/ethers/typechain/IL1AssetRouter.d.ts +570 -0
- package/dist/adapters/ethers/typechain/IL1NativeTokenVault.d.ts +154 -0
- package/dist/adapters/ethers/typechain/IL1Nullifier.d.ts +305 -0
- package/dist/adapters/ethers/typechain/IL2AssetRouter.d.ts +288 -0
- package/dist/adapters/ethers/typechain/IL2NativeTokenVault.d.ts +380 -0
- package/dist/adapters/ethers/typechain/common.d.ts +46 -0
- package/dist/adapters/ethers/typechain/factories/IAssetRouterBase__factory.d.ts +203 -0
- package/dist/adapters/ethers/typechain/factories/IBridgehub__factory.d.ts +998 -0
- package/dist/adapters/ethers/typechain/factories/IERC20__factory.d.ts +177 -0
- package/dist/adapters/ethers/typechain/factories/IL1AssetRouter__factory.d.ts +666 -0
- package/dist/adapters/ethers/typechain/factories/IL1NativeTokenVault__factory.d.ts +234 -0
- package/dist/adapters/ethers/typechain/factories/IL1Nullifier__factory.d.ts +382 -0
- package/dist/adapters/ethers/typechain/factories/IL2AssetRouter__factory.d.ts +327 -0
- package/dist/adapters/ethers/typechain/factories/IL2NativeTokenVault__factory.d.ts +696 -0
- package/dist/adapters/ethers/typechain/factories/index.d.ts +8 -0
- package/dist/adapters/ethers/typechain/index.d.ts +17 -0
- package/dist/adapters/viem/client.cjs +4534 -0
- package/dist/adapters/viem/client.cjs.map +1 -0
- package/dist/adapters/viem/client.d.ts +44 -0
- package/dist/adapters/viem/client.js +5 -0
- package/dist/adapters/viem/errors/error-ops.d.ts +20 -0
- package/dist/adapters/viem/errors/revert.d.ts +25 -0
- package/dist/adapters/viem/index.cjs +7772 -0
- package/dist/adapters/viem/index.cjs.map +1 -0
- package/dist/adapters/viem/index.d.ts +11 -0
- package/dist/adapters/viem/index.js +8 -0
- package/dist/adapters/viem/resources/deposits/context.d.ts +27 -0
- package/dist/adapters/viem/resources/deposits/index.d.ts +46 -0
- package/dist/adapters/viem/resources/deposits/routes/erc20-base.d.ts +2 -0
- package/dist/adapters/viem/resources/deposits/routes/erc20-nonbase.d.ts +2 -0
- package/dist/adapters/viem/resources/deposits/routes/eth-nonbase.d.ts +2 -0
- package/dist/adapters/viem/resources/deposits/routes/eth.d.ts +2 -0
- package/dist/adapters/viem/resources/deposits/routes/types.d.ts +20 -0
- package/dist/adapters/viem/resources/deposits/services/verification.d.ts +7 -0
- package/dist/adapters/viem/resources/token-info.d.ts +34 -0
- package/dist/adapters/viem/resources/utils.d.ts +42 -0
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +22 -0
- package/dist/adapters/viem/resources/withdrawals/index.d.ts +56 -0
- package/dist/adapters/viem/resources/withdrawals/routes/erc20-nonbase.d.ts +2 -0
- package/dist/adapters/viem/resources/withdrawals/routes/eth-nonbase.d.ts +2 -0
- package/dist/adapters/viem/resources/withdrawals/routes/eth.d.ts +2 -0
- package/dist/adapters/viem/resources/withdrawals/routes/types.d.ts +19 -0
- package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +33 -0
- package/dist/adapters/viem/rpc.d.ts +2 -0
- package/dist/adapters/viem/sdk.cjs +6481 -0
- package/dist/adapters/viem/sdk.cjs.map +1 -0
- package/dist/adapters/viem/sdk.d.ts +32 -0
- package/dist/adapters/viem/sdk.js +6 -0
- package/dist/chunk-263G6636.js +36 -0
- package/dist/chunk-3LALBFFE.js +138 -0
- package/dist/chunk-4HLJJKIY.js +262 -0
- package/dist/chunk-6GCT6TLS.js +45 -0
- package/dist/chunk-7M4V3FMT.js +2444 -0
- package/dist/chunk-B77GWPO5.js +339 -0
- package/dist/chunk-BD2LUO5T.js +123 -0
- package/dist/chunk-CGO27P7F.js +2187 -0
- package/dist/chunk-DI2CJDPZ.js +76 -0
- package/dist/chunk-Y75OMFK6.js +4489 -0
- package/dist/core/constants.cjs +39 -0
- package/dist/core/constants.cjs.map +1 -0
- package/dist/core/constants.d.ts +36 -0
- package/dist/core/constants.js +1 -0
- package/dist/core/errors/factory.d.ts +10 -0
- package/dist/core/errors/formatter.d.ts +2 -0
- package/dist/core/errors/rpc.d.ts +4 -0
- package/dist/core/errors/withdrawal-revert-map.d.ts +3 -0
- package/dist/core/index.cjs +552 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/index.js +4 -0
- package/dist/core/internal/abi-registry.d.ts +9 -0
- package/dist/core/internal/abis/IAssetRouterBase.d.ts +198 -0
- package/dist/core/internal/abis/IBaseToken.d.ts +162 -0
- package/dist/core/internal/abis/IBridgehub.d.ts +994 -0
- package/dist/core/internal/abis/IERC20.d.ts +224 -0
- package/dist/core/internal/abis/IL1AssetRouter.d.ts +661 -0
- package/dist/core/internal/abis/IL1Nullifier.d.ts +377 -0
- package/dist/core/internal/abis/IL2AssetRouter.d.ts +690 -0
- package/dist/core/internal/abis/L1NativeTokenVault.d.ts +719 -0
- package/dist/core/internal/abis/L2NativeTokenVault.d.ts +735 -0
- package/dist/core/internal/abis/Mailbox.d.ts +779 -0
- package/dist/core/resources/deposits/route.d.ts +6 -0
- package/dist/core/resources/withdrawals/events.d.ts +9 -0
- package/dist/core/resources/withdrawals/logs.d.ts +5 -0
- package/dist/core/resources/withdrawals/route.d.ts +6 -0
- package/dist/core/rpc/transport.d.ts +10 -0
- package/dist/core/rpc/types.d.ts +40 -0
- package/dist/core/rpc/zks.d.ts +12 -0
- package/dist/core/types/errors.d.ts +177 -0
- package/dist/core/types/flows/base.d.ts +51 -0
- package/dist/core/types/flows/deposits.d.ts +43 -0
- package/dist/core/types/flows/route.d.ts +12 -0
- package/dist/core/types/flows/withdrawals.d.ts +83 -0
- package/dist/core/types/index.d.ts +2 -0
- package/dist/core/types/primitives.d.ts +3 -0
- package/dist/core/utils/addr.d.ts +5 -0
- package/dist/core/utils/gas.d.ts +13 -0
- package/dist/index.cjs +571 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +4 -0
- package/package.json +177 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dustin Brickwood
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ⚡️ zksync-js ⚡️
|
|
4
|
+
|
|
5
|
+
_TypeScript SDK for deposits, withdrawals, and RPC access across the Elastic Network_
|
|
6
|
+
|
|
7
|
+
**Note**: This repository is a successor to the original ZKsync SDK, which can be found at **[dutterbutter/zksync-sdk](https://github.com/dutterbutter/zksync-sdk)**.
|
|
8
|
+
|
|
9
|
+
[](https://github.com/matter-labs/zksync-js/actions/workflows/ci-check.yaml)
|
|
10
|
+
[](https://github.com/matter-labs/zksync-js/releases/latest)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
[](https://x.com/zksync)
|
|
13
|
+
[](https://matter-labs.github.io/zksync-js/)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<b>
|
|
19
|
+
<a href="https://matter-labs.github.io/zksync-js/latest/quickstart/">Quickstart</a> ·
|
|
20
|
+
<a href="https://matter-labs.github.io/zksync-js/">User Book</a> ·
|
|
21
|
+
<a href="./.github/CONTRIBUTING.md">Contributing</a>
|
|
22
|
+
</b>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
## ✨ Features
|
|
26
|
+
|
|
27
|
+
- **Adapters for both worlds** – choose [`viem`](https://viem.sh) or [`ethers`](https://docs.ethers.io)
|
|
28
|
+
- **Deposits (L1 → L2)** – ETH and ERC-20 transfers
|
|
29
|
+
- **Withdrawals (L2 → L1)** – full two-step flows with status tracking + finalization
|
|
30
|
+
- **zks\_ RPC methods** – typed helpers for logProofs, receipts, and bridgehub access
|
|
31
|
+
- **Helper methods** – helpers for l1-l2 token address mapping, contract address fetching
|
|
32
|
+
- **Try-methods** – no-throw style (`tryCreate`, `tryWait`) for UI / services
|
|
33
|
+
|
|
34
|
+
## 📦 Installation
|
|
35
|
+
|
|
36
|
+
Install the adapter you need:
|
|
37
|
+
|
|
38
|
+
<details>
|
|
39
|
+
<summary><strong>viem adapter</strong></summary>
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @matter-labs/zksync-js viem
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</details>
|
|
46
|
+
|
|
47
|
+
<details>
|
|
48
|
+
<summary><strong>ethers adapter</strong></summary>
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install @matter-labs/zksync-js ethers
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
</details>
|
|
55
|
+
|
|
56
|
+
## ⚡️ Quick-start
|
|
57
|
+
|
|
58
|
+
For exhaustive examples please refer to [`./examples`](./examples/) directory.
|
|
59
|
+
|
|
60
|
+
**ETH deposit (ethers)**
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { JsonRpcProvider, Wallet, parseEther } from 'ethers';
|
|
64
|
+
import { createEthersClient, createEthersSdk } from '@matter-labs/zksync-js/ethers';
|
|
65
|
+
import { ETH_ADDRESS } from '@matter-labs/zksync-js/core';
|
|
66
|
+
|
|
67
|
+
const l1Provider = new JsonRpcProvider('https://sepolia.infura.io/v3/...');
|
|
68
|
+
const l2Provider = new JsonRpcProvider('https://zksync-testnet.rpc');
|
|
69
|
+
const signer = new Wallet(process.env.PRIVATE_KEY!, l1Provider);
|
|
70
|
+
|
|
71
|
+
const client = await createEthersClient({ l1Provider, l2Provider, signer });
|
|
72
|
+
const sdk = createEthersSdk(client);
|
|
73
|
+
|
|
74
|
+
const deposit = await sdk.deposits.create({
|
|
75
|
+
token: ETH_ADDRESS,
|
|
76
|
+
amount: parseEther('0.01'),
|
|
77
|
+
to: signer.address,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await sdk.deposits.wait(handle, { for: 'l2' });
|
|
81
|
+
console.log('Deposit complete ✅');
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**ETH deposit (viem)**
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { createPublicClient, createWalletClient, http, parseEther } from 'viem';
|
|
88
|
+
import { createViemClient, createViemSdk } from '@matter-labs/zksync-js/viem';
|
|
89
|
+
import { ETH_ADDRESS } from '@matter-labs/zksync-js/core';
|
|
90
|
+
|
|
91
|
+
const l1 = createPublicClient({ transport: http('https://sepolia.infura.io/v3/...') });
|
|
92
|
+
const l2 = createPublicClient({ transport: http('https://zksync-testnet.rpc') });
|
|
93
|
+
const l1Wallet = createWalletClient({
|
|
94
|
+
account,
|
|
95
|
+
transport: http('https://sepolia.infura.io/v3/...'),
|
|
96
|
+
});
|
|
97
|
+
const client = createViemClient({ l1, l2, l1Wallet });
|
|
98
|
+
const sdk = createViemSdk(client);
|
|
99
|
+
|
|
100
|
+
const handle = await sdk.deposits.create({
|
|
101
|
+
token: ETH_ADDRESS,
|
|
102
|
+
amount: parseEther('0.01'),
|
|
103
|
+
to: account.address,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
await sdk.deposits.wait(handle, { for: 'l2' });
|
|
107
|
+
console.log('Deposit complete ✅');
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
> See [Quickstart docs](https://matter-labs.github.io/zksync-js/quickstart/) for full examples.
|
|
111
|
+
|
|
112
|
+
## 📚 Documentation
|
|
113
|
+
|
|
114
|
+
- [User Book](https://matter-labs.github.io/zksync-sdk/) – guides, concepts, API docs
|
|
115
|
+
- [How-to Guides](https://matter-labs.github.io/zksync-sdk/guides/) – deposits, withdrawals, RPC helpers
|
|
116
|
+
- [Concepts](https://matter-labs.github.io/zksync-sdk/concepts/) – mental model, status vs wait, finalization
|
|
117
|
+
|
|
118
|
+
## 🤝 Contributing
|
|
119
|
+
|
|
120
|
+
Bug reports, fixes, and new features are welcome! Please read the [contributing guide](.github/CONTRIBUTING.md) to get started.
|
|
121
|
+
|
|
122
|
+
## 📜 License
|
|
123
|
+
|
|
124
|
+
This project is licensed under the terms of the **MIT License** – see the [LICENSE](LICENSE) file for details.
|