@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.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/adapters/ethers/client.cjs +4548 -0
  4. package/dist/adapters/ethers/client.cjs.map +1 -0
  5. package/dist/adapters/ethers/client.d.ts +61 -0
  6. package/dist/adapters/ethers/client.js +5 -0
  7. package/dist/adapters/ethers/errors/error-ops.d.ts +20 -0
  8. package/dist/adapters/ethers/errors/revert.d.ts +28 -0
  9. package/dist/adapters/ethers/index.cjs +7537 -0
  10. package/dist/adapters/ethers/index.cjs.map +1 -0
  11. package/dist/adapters/ethers/index.d.ts +12 -0
  12. package/dist/adapters/ethers/index.js +8 -0
  13. package/dist/adapters/ethers/resources/deposits/context.d.ts +27 -0
  14. package/dist/adapters/ethers/resources/deposits/index.d.ts +46 -0
  15. package/dist/adapters/ethers/resources/deposits/routes/erc20-base.d.ts +2 -0
  16. package/dist/adapters/ethers/resources/deposits/routes/erc20-nonbase.d.ts +2 -0
  17. package/dist/adapters/ethers/resources/deposits/routes/eth-nonbase.d.ts +2 -0
  18. package/dist/adapters/ethers/resources/deposits/routes/eth.d.ts +2 -0
  19. package/dist/adapters/ethers/resources/deposits/routes/types.d.ts +10 -0
  20. package/dist/adapters/ethers/resources/deposits/services/verification.d.ts +9 -0
  21. package/dist/adapters/ethers/resources/token-info.d.ts +31 -0
  22. package/dist/adapters/ethers/resources/utils.d.ts +39 -0
  23. package/dist/adapters/ethers/resources/withdrawals/context.d.ts +19 -0
  24. package/dist/adapters/ethers/resources/withdrawals/index.d.ts +56 -0
  25. package/dist/adapters/ethers/resources/withdrawals/routes/erc20-nonbase.d.ts +2 -0
  26. package/dist/adapters/ethers/resources/withdrawals/routes/eth-nonbase.d.ts +2 -0
  27. package/dist/adapters/ethers/resources/withdrawals/routes/eth.d.ts +2 -0
  28. package/dist/adapters/ethers/resources/withdrawals/routes/types.d.ts +18 -0
  29. package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +33 -0
  30. package/dist/adapters/ethers/rpc.d.ts +4 -0
  31. package/dist/adapters/ethers/sdk.cjs +6245 -0
  32. package/dist/adapters/ethers/sdk.cjs.map +1 -0
  33. package/dist/adapters/ethers/sdk.d.ts +29 -0
  34. package/dist/adapters/ethers/sdk.js +6 -0
  35. package/dist/adapters/ethers/typechain/IAssetRouterBase.d.ts +198 -0
  36. package/dist/adapters/ethers/typechain/IBridgehub.d.ts +731 -0
  37. package/dist/adapters/ethers/typechain/IERC20.d.ts +108 -0
  38. package/dist/adapters/ethers/typechain/IL1AssetRouter.d.ts +570 -0
  39. package/dist/adapters/ethers/typechain/IL1NativeTokenVault.d.ts +154 -0
  40. package/dist/adapters/ethers/typechain/IL1Nullifier.d.ts +305 -0
  41. package/dist/adapters/ethers/typechain/IL2AssetRouter.d.ts +288 -0
  42. package/dist/adapters/ethers/typechain/IL2NativeTokenVault.d.ts +380 -0
  43. package/dist/adapters/ethers/typechain/common.d.ts +46 -0
  44. package/dist/adapters/ethers/typechain/factories/IAssetRouterBase__factory.d.ts +203 -0
  45. package/dist/adapters/ethers/typechain/factories/IBridgehub__factory.d.ts +998 -0
  46. package/dist/adapters/ethers/typechain/factories/IERC20__factory.d.ts +177 -0
  47. package/dist/adapters/ethers/typechain/factories/IL1AssetRouter__factory.d.ts +666 -0
  48. package/dist/adapters/ethers/typechain/factories/IL1NativeTokenVault__factory.d.ts +234 -0
  49. package/dist/adapters/ethers/typechain/factories/IL1Nullifier__factory.d.ts +382 -0
  50. package/dist/adapters/ethers/typechain/factories/IL2AssetRouter__factory.d.ts +327 -0
  51. package/dist/adapters/ethers/typechain/factories/IL2NativeTokenVault__factory.d.ts +696 -0
  52. package/dist/adapters/ethers/typechain/factories/index.d.ts +8 -0
  53. package/dist/adapters/ethers/typechain/index.d.ts +17 -0
  54. package/dist/adapters/viem/client.cjs +4534 -0
  55. package/dist/adapters/viem/client.cjs.map +1 -0
  56. package/dist/adapters/viem/client.d.ts +44 -0
  57. package/dist/adapters/viem/client.js +5 -0
  58. package/dist/adapters/viem/errors/error-ops.d.ts +20 -0
  59. package/dist/adapters/viem/errors/revert.d.ts +25 -0
  60. package/dist/adapters/viem/index.cjs +7772 -0
  61. package/dist/adapters/viem/index.cjs.map +1 -0
  62. package/dist/adapters/viem/index.d.ts +11 -0
  63. package/dist/adapters/viem/index.js +8 -0
  64. package/dist/adapters/viem/resources/deposits/context.d.ts +27 -0
  65. package/dist/adapters/viem/resources/deposits/index.d.ts +46 -0
  66. package/dist/adapters/viem/resources/deposits/routes/erc20-base.d.ts +2 -0
  67. package/dist/adapters/viem/resources/deposits/routes/erc20-nonbase.d.ts +2 -0
  68. package/dist/adapters/viem/resources/deposits/routes/eth-nonbase.d.ts +2 -0
  69. package/dist/adapters/viem/resources/deposits/routes/eth.d.ts +2 -0
  70. package/dist/adapters/viem/resources/deposits/routes/types.d.ts +20 -0
  71. package/dist/adapters/viem/resources/deposits/services/verification.d.ts +7 -0
  72. package/dist/adapters/viem/resources/token-info.d.ts +34 -0
  73. package/dist/adapters/viem/resources/utils.d.ts +42 -0
  74. package/dist/adapters/viem/resources/withdrawals/context.d.ts +22 -0
  75. package/dist/adapters/viem/resources/withdrawals/index.d.ts +56 -0
  76. package/dist/adapters/viem/resources/withdrawals/routes/erc20-nonbase.d.ts +2 -0
  77. package/dist/adapters/viem/resources/withdrawals/routes/eth-nonbase.d.ts +2 -0
  78. package/dist/adapters/viem/resources/withdrawals/routes/eth.d.ts +2 -0
  79. package/dist/adapters/viem/resources/withdrawals/routes/types.d.ts +19 -0
  80. package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +33 -0
  81. package/dist/adapters/viem/rpc.d.ts +2 -0
  82. package/dist/adapters/viem/sdk.cjs +6481 -0
  83. package/dist/adapters/viem/sdk.cjs.map +1 -0
  84. package/dist/adapters/viem/sdk.d.ts +32 -0
  85. package/dist/adapters/viem/sdk.js +6 -0
  86. package/dist/chunk-263G6636.js +36 -0
  87. package/dist/chunk-3LALBFFE.js +138 -0
  88. package/dist/chunk-4HLJJKIY.js +262 -0
  89. package/dist/chunk-6GCT6TLS.js +45 -0
  90. package/dist/chunk-7M4V3FMT.js +2444 -0
  91. package/dist/chunk-B77GWPO5.js +339 -0
  92. package/dist/chunk-BD2LUO5T.js +123 -0
  93. package/dist/chunk-CGO27P7F.js +2187 -0
  94. package/dist/chunk-DI2CJDPZ.js +76 -0
  95. package/dist/chunk-Y75OMFK6.js +4489 -0
  96. package/dist/core/constants.cjs +39 -0
  97. package/dist/core/constants.cjs.map +1 -0
  98. package/dist/core/constants.d.ts +36 -0
  99. package/dist/core/constants.js +1 -0
  100. package/dist/core/errors/factory.d.ts +10 -0
  101. package/dist/core/errors/formatter.d.ts +2 -0
  102. package/dist/core/errors/rpc.d.ts +4 -0
  103. package/dist/core/errors/withdrawal-revert-map.d.ts +3 -0
  104. package/dist/core/index.cjs +552 -0
  105. package/dist/core/index.cjs.map +1 -0
  106. package/dist/core/index.d.ts +18 -0
  107. package/dist/core/index.js +4 -0
  108. package/dist/core/internal/abi-registry.d.ts +9 -0
  109. package/dist/core/internal/abis/IAssetRouterBase.d.ts +198 -0
  110. package/dist/core/internal/abis/IBaseToken.d.ts +162 -0
  111. package/dist/core/internal/abis/IBridgehub.d.ts +994 -0
  112. package/dist/core/internal/abis/IERC20.d.ts +224 -0
  113. package/dist/core/internal/abis/IL1AssetRouter.d.ts +661 -0
  114. package/dist/core/internal/abis/IL1Nullifier.d.ts +377 -0
  115. package/dist/core/internal/abis/IL2AssetRouter.d.ts +690 -0
  116. package/dist/core/internal/abis/L1NativeTokenVault.d.ts +719 -0
  117. package/dist/core/internal/abis/L2NativeTokenVault.d.ts +735 -0
  118. package/dist/core/internal/abis/Mailbox.d.ts +779 -0
  119. package/dist/core/resources/deposits/route.d.ts +6 -0
  120. package/dist/core/resources/withdrawals/events.d.ts +9 -0
  121. package/dist/core/resources/withdrawals/logs.d.ts +5 -0
  122. package/dist/core/resources/withdrawals/route.d.ts +6 -0
  123. package/dist/core/rpc/transport.d.ts +10 -0
  124. package/dist/core/rpc/types.d.ts +40 -0
  125. package/dist/core/rpc/zks.d.ts +12 -0
  126. package/dist/core/types/errors.d.ts +177 -0
  127. package/dist/core/types/flows/base.d.ts +51 -0
  128. package/dist/core/types/flows/deposits.d.ts +43 -0
  129. package/dist/core/types/flows/route.d.ts +12 -0
  130. package/dist/core/types/flows/withdrawals.d.ts +83 -0
  131. package/dist/core/types/index.d.ts +2 -0
  132. package/dist/core/types/primitives.d.ts +3 -0
  133. package/dist/core/utils/addr.d.ts +5 -0
  134. package/dist/core/utils/gas.d.ts +13 -0
  135. package/dist/index.cjs +571 -0
  136. package/dist/index.cjs.map +1 -0
  137. package/dist/index.d.ts +18 -0
  138. package/dist/index.js +4 -0
  139. 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
+ [![CI Status](https://github.com/matter-labs/zksync-js/actions/workflows/ci-check.yaml/badge.svg)](https://github.com/matter-labs/zksync-js/actions/workflows/ci-check.yaml)
10
+ [![Release](https://img.shields.io/github/v/release/matter-labs/zksync-js?label=version)](https://github.com/matter-labs/zksync-js/releases/latest)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
12
+ [![X: @zksync](https://img.shields.io/badge/follow-@zksync-1DA1F2?logo=x)](https://x.com/zksync)
13
+ [![User Book](https://img.shields.io/badge/docs-user%20book-brightgreen)](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.