diff --git a/content/sdk/10.js/00.ethers/00.index.md b/content/sdk/10.js/00.ethers/00.index.md index e2fd9d30..da1c4ad1 100644 --- a/content/sdk/10.js/00.ethers/00.index.md +++ b/content/sdk/10.js/00.ethers/00.index.md @@ -1,39 +1,32 @@ --- title: Overview -description: Explore zksync-ethers SDK versions +description: Explore the zksync-ethers SDK versions tags: ["zksync", "sdks", "zksync Era SDK", "ethereum", "era network", "javascript versions"] --- -These versions help developers interact with the ZKsync Era blockchain. It covers most common -operations developers require and provides a starting point for those new to the ZKsync Era. +The zksync-ethers SDK versions enable developers to interact seamlessly with the ZKsync Era blockchain. These SDKs +support common operations developers require and serve as an excellent starting point for those new to the ZKsync Era. -::callout -Take a look at the [migration guide](/sdk/js/ethers/v6/migration) if you are migrating from `zksync-web3`. -:: - -### Prerequisites - -- Node: >=v18 ([installation guide](https://nodejs.org/en/download/package-manager)) - -### Installation +## Available SDK versions -To install SDK for ZKsync Era, follow the process below: +There are two main versions of the zksync-ethers SDK: V5 and V6. Each version caters to different needs and provides +distinct features and improvements. -- Install `zksync-ethers` and `ethers` packages: +::callout +For installation instructions, check out the [installation guide](/sdk/js/ethers/installation-js). +:: -::code-group +## Choosing the right version -```sh [ethers-v5] -yarn add zksync-ethers@5 -yarn add ethers@5 # ethers is a peer dependency of zksync-ethers -``` +Choosing the right version of the zksync-ethers SDK depends on your project requirements and development goals. Here is + a quick comparison to help you decide: -```sh [ethers-v6] -yarn add zksync-ethers -yarn add ethers@6 # ethers is a peer dependency of zksync-ethers -``` - -:: +| Feature | V5 | V6 | +|-----------------|--------------------------------------|---------------------------------------| +| Stability | Highly stable | Latest features, ongoing improvements | +| Performance | Standard performance | Enhanced performance | +| Usability | Comprehensive documentation | Refined API design | +| Community Support| Extensive community resources | Growing community support | For more detailed information, learn more! @@ -43,12 +36,13 @@ For more detailed information, learn more! title: V5 to: /sdk/js/ethers/v5/getting-started --- -Integrate zksync-ethers JS SDK for ZKsync Era features. +Integrate the zksync-ethers JS SDK V5 for ZKsync Era features. :: ::card --- title: V6 to: /sdk/js/ethers/v6/getting-started --- -Integrate zksync-ethers JS SDK for ZKsync Era features. +Integrate the zksync-ethers JS SDK V6 for ZKsync Era features. +:: :: diff --git a/content/sdk/10.js/00.ethers/01.installation-js.md b/content/sdk/10.js/00.ethers/01.installation-js.md new file mode 100644 index 00000000..9fdccaa7 --- /dev/null +++ b/content/sdk/10.js/00.ethers/01.installation-js.md @@ -0,0 +1,50 @@ +--- +title: Installation +description: How to install and set up zksync-ethers for your project. +tags: ["zksync", "installation", "setup", "ethereum", "sdk"] +--- + +## JavaScript + +Learn how to install and set up the `zksync-ethers` library to interact with the ZKsync network, leveraging its +features for Ethereum scaling and Layer 2 solutions. + +::callout +If you're migrating from `zksync-web3`, please refer to the [migration guide](/sdk/js/ethers/v6/migration) for detailed instructions. +:: + +### Prerequisites + +Ensure you have the following installed on your machine: + +- [Node.js](https://nodejs.org/) (version 14.x or later) +- [npm](https://www.npmjs.com/) (version 6.x or later) or [yarn](https://yarnpkg.com/) (version 1.x or later) + +### Installation steps + +#### Step 1: Initialize your project + +Create a new Node.js project or navigate to your existing project directory. + +```bash +mkdir my-zksync-project +cd my-zksync-project +npm init -y +``` + +#### Step 2: Install zksync-ethers + +Install the `zksync-ethers` library along with its peer dependency, `ethers`. Choose the appropriate +version of `ethers` based on your needs. + +::code-group + +```sh [ethers-v5] +npm install zksync-ethers@5 ethers@5 +``` + +```sh [ethers-v6] +npm install zksync-ethers ethers@6 +``` + +:: diff --git a/content/sdk/10.js/00.ethers/02.why-zksync-ethers.md b/content/sdk/10.js/00.ethers/02.why-zksync-ethers.md new file mode 100644 index 00000000..daa331fa --- /dev/null +++ b/content/sdk/10.js/00.ethers/02.why-zksync-ethers.md @@ -0,0 +1,42 @@ +--- +title: Why zksync-ethers +description: Benefits and features of the zksync-ethers for ZKsync Era. +tags: ["zksync", "ethers", "sdk", "javascript", "ethereum"] +--- + +### Problem + +To provide easy access to all the features of ZKsync Era, the `zksync-ethers` JavaScript SDK was created with an +interface very similar to [ethers](https://docs.ethers.io/v6/). In fact, `ethers` is a peer dependency of our library, +and most of the objects exported by `zksync-ethers` (e.g., `Wallet`, `Provider`, etc.) inherit from the +corresponding `ethers` objects and override only the fields that need to be changed. + +The library is designed so that after replacing `ethers` with `zksync-ethers`, most client applications will work out +of the box. + +### Developer experience + +The `zksync-ethers` SDK offers an enhanced developer experience by closely mirroring the interface and usage patterns +of `ethers`, making it easy for developers familiar with `ethers` to transition. This seamless integration means +that interacting with the ZKsync Era blockchain is straightforward and intuitive, reducing the learning curve and +increasing productivity. Developers can leverage the extensive `ethers` documentation and community support while +benefiting from the unique features of the ZKsync Era. + +### Stability + +The `zksync-ethers` SDK is rigorously tested and backed by comprehensive documentation, ensuring a stable and reliable +user experience. Each feature and functionality is covered by tests, and detailed guides are available to assist +developers in troubleshooting and maximizing the potential of the SDK. This focus on stability and support helps +developers confidently build and deploy applications on the ZKsync Era blockchain. + +### Extensibility + +The `zksync-ethers` SDK is designed with extensibility in mind. The architecture allows for easy integration of new +features and improvements, ensuring compatibility with future advancements in ZKsync and other zk-rollup +technologies. The SDK is regularly updated to incorporate the latest developments, providing developers with a +powerful and flexible tool for building next-generation blockchain applications. + +::callout +Explore the [zksync-ethers documentation](/sdk/js/ethers) to get started and take advantage of all the +features and benefits it offers. +:: diff --git a/content/sdk/10.js/00.ethers/10.v5/00.getting-started.md b/content/sdk/10.js/00.ethers/10.v5/00.getting-started.md index 89acaccb..88522989 100644 --- a/content/sdk/10.js/00.ethers/10.v5/00.getting-started.md +++ b/content/sdk/10.js/00.ethers/10.v5/00.getting-started.md @@ -12,3 +12,126 @@ ensuring smoother and more efficient workflows. This version is now obsolete. For continued support and access to the latest features and improvements, please migrate to [version 6](/sdk/js/ethers/v6/getting-started) for better performance and new features. :: + +However, ZKsync still supports Ethers v5, and this is how to get started: + +## Installation + +Install the `zksync-ethers` library: + +```bash +npm install zksync-ethers ethers +``` + +## Initialization + +To initialize the provider to connect to the %%zk_testnet_name%%: + +```typescript +import { Provider, types } from "zksync-ethers"; + +const provider = Provider.getDefaultProvider(types.Network.Sepolia); +``` + +## Network information + +To fetch details about the connected network and the current block number: + +```typescript +(async () => { + const network = await provider.getNetwork(); + const blockNumber = await provider.getBlockNumber(); + console.log(`Network: ${JSON.stringify(network)}`); + console.log(`Block number: ${blockNumber}`); +})(); +``` + +## Transaction details + +To fetch transaction details: + +```typescript +(async () => { + const transactionHash = "0xaa065e5a57e1f8470a6f258e2b6eee87c547eab066b8620ce7f3fd51405665e1"; + const result = await provider.getTransactionDetails(transactionHash); + console.log(`Transaction Details: ${JSON.stringify(result)}`); +})(); +``` + +## Error handling + +Wrap the main logic in a try-catch block to handle potential errors: + +```typescript +(async () => { + try { + // Your code here + } catch (error) { + console.error(`Error fetching transaction details from ZKsync: ${error}`); + } +})(); +``` + +## Example code + +Here is an example script demonstrating the usage of the SDK: + +```typescript +import { Provider, types } from "zksync-ethers"; + +async function main() { + const provider = Provider.getDefaultProvider(types.Network.Sepolia); + + const network = await provider.getNetwork(); + const blockNumber = await provider.getBlockNumber(); + console.log(`Network: ${JSON.stringify(network)}`); + console.log(`Block number: ${blockNumber}`); + + const transactionHash = "0xaa065e5a57e1f8470a6f258e2b6eee87c547eab066b8620ce7f3fd51405665e1"; + + try { + const result = await provider.getTransactionDetails(transactionHash); + if (result) { + console.log(`Transaction Details from ZKsync: ${JSON.stringify(result)}`); + console.log(`ethCommitTxHash: ${result.ethCommitTxHash}`); + console.log(`ethExecuteTxHash: ${result.ethExecuteTxHash}`); + console.log(`ethProveTxHash: ${result.ethProveTxHash}`); + } else { + console.log(`Transaction with hash ${transactionHash} not found in ZKsync.`); + } + } catch (error) { + console.error(`Error fetching transaction details from ZKsync: ${error}`); + } +} + +main() + .then(() => console.log("Script executed successfully")) + .catch((error) => console.error(`Error executing script: ${error}`)); +``` + +## Run the script + +Use the following command to run the script: + +```bash +npx ts-node +``` + +## Output + +Example output when the script runs successfully: + +```sh +Network: {"name":"unknown","chainId":"300"} +Block number: 2725282 +Transaction Details from ZKsync: {"ethCommitTxHash":"0xfe921b3af6bf14d35d6c550f1a337f20a46997a36c24bae37c1b2d129ee3b4d6","ethExecuteTxHash":"0x08e42763d6ba1052d117174acbb708d9e015ae9246574cf9d9b06c001b31e750","ethProveTxHash":"0x49ab3b1a7cc72911492afe39f21d5f557abcb2769aa63841f658c719a7ec5ba2","fee":"0x1252b3c112d2e","gasPerPubdata":"0xc350","initiatorAddress":"0xb71ce978bf48e3e4669a7a0acb89850023fc3279","isL1Originated":false,"receivedAt":"2024-06-03T09:16:41.519Z","status":"verified"} +ethCommitTxHash: 0xfe921b3af6bf14d35d6c550f1a337f20a46997a36c24bae37c1b2d129ee3b4d6 +ethExecuteTxHash: 0x08e42763d6ba1052d117174acbb708d9e015ae9246574cf9d9b06c001b31e750 +ethProveTxHash: 0x49ab3b1a7cc72911492afe39f21d5f557abcb2769aa63841f658c719a7ec5ba2 +Script executed successfully +``` + +::callout{icon="i-heroicons-light-bulb"} +If you encounter any error while using the zksync-ethers v5, kindly visit the +[Troubleshooting Guide](/sdk/troubleshooting#javascript-sdk) for more information. +:: diff --git a/content/sdk/10.js/00.ethers/10.v5/01.features.md b/content/sdk/10.js/00.ethers/10.v5/01.features.md index d7a1c25f..795e89bf 100644 --- a/content/sdk/10.js/00.ethers/10.v5/01.features.md +++ b/content/sdk/10.js/00.ethers/10.v5/01.features.md @@ -1,99 +1,110 @@ --- -title: ZKsync Era Features -description: + +title: ZKsync Era Features +description: Explore ZKsync Era features and custom transactions +tags: ["zksync", "ethereum", "zksync Era", "transactions", "paymasters"] + --- -While ZKsync is mostly Web3-compatible, it has some differences compared to Ethereum. The major of those are: +ZKsync Era, while mostly Web3-compatible, has key differences compared to Ethereum: -- Account abstraction support (accounts may have near-arbitrary validation logic, and also paymaster - support is enabled). -- Deployment transactions require the contracts' bytecode to be passed in a separate field. -- The fee system is somewhat different. +- **Account Abstraction Support**: Allows near-arbitrary validation logic and enables paymaster support. +- **Deployment Transactions**: Contracts' bytecode must be passed in a separate field. +- **Fee System**: Requires additional fields in transactions. -These require us to extend standard Ethereum transactions with new custom fields. Such extended transactions -are called EIP712 transactions since [EIP712](https://eips.ethereum.org/EIPS/eip-712) is used to sign them. -You can look at the internal structure of the EIP712 transactions [here](https://docs.zksync.io/zk-stack/concepts/transaction-lifecycle.html#eip-712-0x71). +These differences necessitate extending standard Ethereum transactions with new custom fields, known as EIP712 +transactions. Refer to the ZKsync documentation on Transaction Lifecycle for details on [EIP712 transactions](https://docs.zksync.io/zk-stack/concepts/transaction-lifecycle#eip-712-0x71). -This document will focus solely on how to pass these arguments to the SDK. +::callout{icon="i-heroicons-light-bulb"} +This guide focuses on passing these arguments to the SDK. +:: ## Overrides -`ethers.js` has a notion of overrides. For any on-chain transaction, `ethers.js` finds the optimal -`gasPrice`, `gasLimit`, `nonce`, and other important fields under the hood. But sometimes, you may -have a need to explicitly provide these values (you want to set a smaller `gasPrice` for instance, -or sign a transaction with future `nonce`). +`ethers.js` has a notion of overrides. For any on-chain transaction, `ethers.js` finds the optimal `gasPrice`, +`gasLimit`, `nonce`, and other important fields under the hood. But sometimes, you may have a need to explicitly +provide these values (e.g., setting a smaller `gasPrice` or signing a transaction with a future `nonce`). -In this case, you can provide an `Overrides` object as the last parameter. -There you can supply fields like `gasPrice`, `gasLimit`, `nonce` etc. +In such cases, you can provide an `Overrides` object as the last parameter. There, you can supply fields like +`gasPrice`, `gasLimit`, `nonce`, etc. -In order to make the SDK as flexible as possible, `zksync-ethers` uses `customData` object in the -overrides to supply ZKsync-specific fields. To supply ZKsync-specific fields, you -need to pass the following override: +To make the SDK as flexible as possible, `zksync-ethers` uses the `customData` object in the overrides to supply +ZKsync-specific fields. To supply ZKsync-specific fields, you need to pass the following override: ```typescript { - overrides: { - customData: { - gasPerPubdata?: BigNumberish; - factoryDeps?: BytesLike[]; - customSignature?: BytesLike; - paymasterParams?: { - paymaster: Address; - paymasterInput: BytesLike; - }; - } + overrides: { + customData: { + gasPerPubdata?: BigNumberish; + factoryDeps?: BytesLike[]; + customSignature?: BytesLike; + paymasterParams?: { + paymaster: Address; + paymasterInput: BytesLike; + }; } + } } ``` -Please note once again: everything that is inside `customData` in `overrides` is related to ZKsync(L2 gas, etc.). +::callout{icon="i-heroicons-light-bulb"} +Everything that is inside `customData` in `overrides` is related to ZKsync (L2 gas, etc.). +:: + +### CustomData fields -Examples: +- `gasPerPubdata`: Specifies L2 gas per published byte. +- `factoryDeps`: Array of contract bytecodes for deployment. +- `customSignature`: Custom signature for the transaction. +- `paymasterParams`: Parameters for using a paymaster. -Override to deploy a contract with bytecode `0xcde...12` and enforce that the operator will not charge more than -`100` L2 gas per published bytes on Layer 1: +## Example overrides + +### Contract deployment + +Override to deploy a contract with bytecode `0xcde...12` and enforce that the operator will not charge more than `100` +L2 gas per published bytes on Layer 1: ```typescript { - customData: { - gasPerPubdata: "100", - factoryDeps: ["0xcde...12"], - } + customData: { + gasPerPubdata: "100", + factoryDeps: ["0xcde...12"], + } } ``` -Use custom signature `0x123456` for account, while using paymaster with address -`0x8e1DC7E4Bb15927E76a854a92Bf8053761501fdC` and paymaster input `0x8c5a3445`: +### Custom signature and paymaster + +Use custom signature `0x123456` for the account, while using paymaster with +address `0x8e1DC7E4Bb15927E76a854a92Bf8053761501fdC` and paymaster input `0x8c5a3445`: ```typescript { - customData: { - customSignature: "0x123456", - paymasterParams: { - paymaster: "0x8e1DC7E4Bb15927E76a854a92Bf8053761501fdC", - paymasterInput: "0x8c5a3445" - } + customData: { + customSignature: "0x123456", + paymasterParams: { + paymaster: "0x8e1DC7E4Bb15927E76a854a92Bf8053761501fdC", + paymasterInput: "0x8c5a3445" } + } } ``` ## Encoding paymaster params -While the paymaster feature by itself does not impose any limitations on values of the -`paymasterInput`, the Matter Labs team endorses certain types of -[paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction.html#built-in-paymaster-flows) +While the paymaster feature itself does not impose any limitations on values of the `paymasterInput`, the Matter Labs +team endorses certain types of [paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction.html#built-in-paymaster-flows) that are processable by EOAs. -ZKsync SDK provides a utility method that can be used to get the correctly formed `paymasterParams` object: -[getPaymasterParams](/sdk/js/ethers/v5/paymaster-utils#getpaymasterparams). +The ZKsync SDK provides a utility method that can be used to get the correctly formed `paymasterParams` object: [getPaymasterParams](/sdk/js/ethers/v5/paymaster-utils#getpaymasterparams). -## See in action +## Using a paymaster with a contract method -If you want to call the method `setGreeting` of an ethers `Contract` object called `greeter`, -this would look the following way, while paying fees with the -[testnet paymaster](https://docs.zksync.io/build/developer-reference/account-abstraction.html#testnet-paymaster): +If you want to call the `setGreeting` method of an ethers `Contract` object called `greeter`, this would look the +following way, while paying fees with the [testnet paymaster](https://docs.zksync.io/build/developer-reference/account-abstraction.html#testnet-paymaster): -```ts +```typescript // The `setGreeting` method has a single parameter -- new greeting // We will set its value as `a new greeting`. const greeting = "a new greeting"; diff --git a/content/sdk/10.js/00.ethers/10.v5/02.front-end.md b/content/sdk/10.js/00.ethers/10.v5/02.front-end.md index 25f6c3a5..61e5c867 100644 --- a/content/sdk/10.js/00.ethers/10.v5/02.front-end.md +++ b/content/sdk/10.js/00.ethers/10.v5/02.front-end.md @@ -1,16 +1,17 @@ --- -title: Front-end Integration -description: +title: Frontend Integration +description: How to integrate ZKsync Era for optimal user experience +tags: ["zksync", "ethereum", "zksync era", "transactions", "frontend"] --- -This section describes how to make the most of ZKsync to provide the best UX. +Learn how to integrate ZKsync Era into your front-end for the best user experience. -## Going to production right away +## Immediate production deployment -If your front-end code does not deploy new smart contracts, then no changes to the codebase are required! -All the existing SDKs/infrastructure will work out-of-box. +If your front-end does not deploy new smart contracts, you don't need to change your codebase! All existing SDKs and +infrastructure will work seamlessly. -## Enabling ZKsync features +## Using ZKsync Era features -If you want to deploy smart contracts or enable advanced ZKsync features, like account abstraction, -then you need to use the `zksync-ethers` library. You can read about the basics [here](/sdk/js/ethers/v5/features). +To deploy smart contracts or use advanced zksync features like account abstraction, you'll need the `zksync-ethers` +library. Learn the basics of `zksync-ethers` in the [ZKsync Era Features](/sdk/js/ethers/v6/features). diff --git a/content/sdk/10.js/00.ethers/10.v5/03.providers.md b/content/sdk/10.js/00.ethers/10.v5/03.providers.md index b9766dae..ccf3cd52 100644 --- a/content/sdk/10.js/00.ethers/10.v5/03.providers.md +++ b/content/sdk/10.js/00.ethers/10.v5/03.providers.md @@ -1,38 +1,35 @@ --- title: Providers -description: +description: A guide to Web3 Provider objects for ZKsync integration +tags: ["zksync", "ethereum", "zksync Era", "transactions", "provider"] --- A Web3 Provider object provides application-layer access to underlying blockchain networks. -The [`zksync-ethers`](https://www.npmjs.com/package/zksync-ethers/v/5.0.0) library supports -provider methods from the [`ethers.js`](https://docs.ethers.io/v5/api/providers) library and -supplies additional functionality. +The [`zksync-ethers`](https://www.npmjs.com/package/zksync-ethers/v/5.0.0) library supports provider methods from +the [`ethers.js`](https://docs.ethers.io/v5/api/providers) library and supplies additional functionality. -Two providers are available: +## Available providers -- [`Provider`](#provider): Supplies the same functionality as - [`ethers.providers.JsonRpcProvider`](https://docs.ethers.org/v5/api/providers/jsonrpc-provider/#JsonRpcProvider) - and extends it with ZKsync-specific methods. -- [`Web3Provider`](#web3provider): Extends the ZKsync Era [`Provider`](#provider) class to make it more compatible - with Web3 wallets. +- **Provider**: Extends [`ethers.JsonRpcProvider`](https://docs.ethers.org/v5/api/providers/jsonrpc/#about-jsonrpcProvider) +with ZKsync specific methods. +- **BrowserProvider**: Extends the ZKsync Era `Provider` class for better compatibility with Web3 wallets. ::callout{icon="i-heroicons-light-bulb"} -Use the [`Web3Provider`](#web3provider) for browser integrations. +Use `BrowserProvider` for browser integrations. :: ## `Provider` ### `constructor` - Returns a ZKsync Era `Provider` object. #### Inputs | Parameter | Type | Description | | ---------- | -------------------------------------------------------------------------------------- | -------------------------- | -| `url?` | string or [`ConnectionInfo`](https://docs.ethers.org/v5/api/utils/web/#ConnectionInfo) | Network RPC URL (optional) | -| `network?` | `ethers.providers.Networkish` | Network name (optional) | +| `url?` | string or [`ConnectionInfo`](https://docs.ethers.org/v5/api/utils/web/#ConnectionInfo) | Network RPC URL | +| `network?` | `ethers.providers.Networkish` | Network name | ```ts constructor(url?: ConnectionInfo | string, network?: ethers.providers.Networkish) @@ -175,10 +172,10 @@ to get the transfer transaction and sends it to the [`estimateGas`](#estimategas | ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | Token address. | | `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasTransfer(transaction: { @@ -219,11 +216,11 @@ withdrawal transaction and sends it to the [`estimateGas`](#estimategas) method. | ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | Token address. | | `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `bridgeAddress?` | `Address` | Bridge address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `bridgeAddress?` | `Address` | Bridge address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasWithdraw(transaction: { @@ -262,11 +259,11 @@ Returns gas estimation for an L1 to L2 execute operation. | -------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------- | | `contractAddress` | `Address` | Address of contract. | | `calldata` | `BytesLike` | The transaction call data. | -| `caller?` | `Address` | Caller address (optional). | -| `l2Value?` | `BigNumberish` | Current L2 gas value (optional). | +| `caller?` | `Address` | Caller address. | +| `l2Value?` | `BigNumberish` | Current L2 gas value. | | `factoryDeps?` | `BytesLike[]` | Byte array containing contract bytecode. | -| `gasPerPubdataByte?` | `BigNumberish` | Constant representing current amount of gas per byte (optional). | -| `overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `gasPerPubdataByte?` | `BigNumberish` | Constant representing current amount of gas per byte. | +| `overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateL1ToL2Execute(transaction: { @@ -314,7 +311,7 @@ async getAllAccountBalances(address: Address): Promise #### Example -Helper function: [toJSON](#tojson). +Helper function: [toJSON](/sdk/js/ethers/v5/providers#tojson). ```ts import { Provider, types } from "zksync-ethers"; @@ -326,7 +323,7 @@ console.log(`All balances: ${toJSON(balances)}`); ### `getBalance` -Returns the user's balance as a `BigNumber` object for an (optional) block tag and (optional) token. +Returns the user's balance as a `BigNumber` object for an block tag and (optional) token. When block and token are not supplied, `committed` and `ETH` are the default values. @@ -335,8 +332,8 @@ When block and token are not supplied, `committed` and `ETH` are the default val | Parameter | Type | Description | | --------------- | ---------- | ------------------------------------------------------------------------------------- | | `address` | `Address` | Account address. | -| `blockTag?` | `BlockTag` | Block tag for getting the balance on. Latest `committed` block is default (optional). | -| `tokenAddress?` | `Address` | Token address. ETH is default (optional). | +| `blockTag?` | `BlockTag` | Block tag for getting the balance on. Latest `committed` block is default. | +| `tokenAddress?` | `Address` | Token address. ETH is default. | ```ts async getBalance(address: Address, blockTag?: BlockTag, tokenAddress?: Address) @@ -824,7 +821,7 @@ Calls the [`zks_getL2ToL1LogProof`](https://docs.zksync.io/build/api-reference/z | Parameter | Type | Description | | --------- | ----------- | ---------------------------------------------------------------- | | `txHash` | `BytesLike` | Hash of the L2 transaction the L2 to L1 log was produced within. | -| `index?` | `number` | The index of the L2 to L1 log in the transaction (optional). | +| `index?` | `number` | The index of the L2 to L1 log in the transaction. | ```ts async getLogProof(txHash: BytesLike, index ? : number): Promise @@ -898,7 +895,7 @@ Returns the transaction confirmation data that is part of `L2->L1` message. | Name | Type | Description | |----------| ----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `txHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0. | ```ts async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ @@ -1201,10 +1198,10 @@ Returns the populated transfer transaction. | ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | Token address. | | `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getTransferTx(transaction: { @@ -1269,11 +1266,11 @@ Returns the populated withdrawal transaction. | ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | Token address. | | `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `bridgeAddress?` | `Address` | Bridge address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `bridgeAddress?` | `Address` | Bridge address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getWithdrawTx(transaction: { @@ -1560,6 +1557,10 @@ const txWithOutputs = await provider.sendRawTransactionWithDetailedOutput( console.log(`Transaction with detailed output: ${utils.toJSON(txWithOutputs)}`); ``` +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + ### `sendTransaction` Override of [Ethers implementation.](https://docs.ethers.org/v5/api/providers/provider/#Provider-sendTransaction) @@ -1607,7 +1608,7 @@ an `ExternalProvider` instead of a node URL. | Parameter | Type | Description | | ---------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | `provider` | [`ExternalProvider`](https://docs.ethers.org/v5/api/providers/other/#Web3Provider--ExternalProvider)) | The `ethers.providers.ExternalProvider` class instance. For instance, Metamask is `window.ethereum`. | -| `network?` | `Networkish` | The description of the network (optional). | +| `network?` | `Networkish` | The description of the network. | ```typescript constructor(provider: ExternalProvider, network?: ethers.providers.Networkish) @@ -1656,7 +1657,7 @@ Override of [Ethers implementation](https://docs.ethers.org/v5/api/providers/jso | Parameter | Type | Description | | ----------------- | -------------------- | ------------------------------------ | -| `addressOrIndex?` | `number` or `string` | Account address or index (optional). | +| `addressOrIndex?` | `number` or `string` | Account address or index. | ```ts getSigner(addressOrIndex?: number | string): Signer @@ -1681,7 +1682,7 @@ Returns a provider request object by overriding the | Parameter | Type | Description | | --------- | ------------ | ---------------------------------- | | `method` | `Address` | Request method name as string. | -| `params?` | `Array` | Parameters of any type (optional). | +| `params?` | `Array` | Parameters of any type. | ```ts async send(method: string, params?: Array): Promise diff --git a/content/sdk/10.js/00.ethers/10.v5/04.accounts.md b/content/sdk/10.js/00.ethers/10.v5/04.accounts.md index 80f83126..c6c09573 100644 --- a/content/sdk/10.js/00.ethers/10.v5/04.accounts.md +++ b/content/sdk/10.js/00.ethers/10.v5/04.accounts.md @@ -1,6 +1,7 @@ --- title: Accounts -description: +description: Manage accounts and sign transactions in zksync-ethers. +tag: ["zksync", "account management", "wallet creation", "transaction signing", "cryptocurrency", "Ethereum"] --- ## Overview @@ -26,8 +27,8 @@ description: | Parameter | Type | Description | | ------------- |-----------------------------------------------------------------------------------------------| ---------------------------------------------------------------------- | | `privateKey` | `BytesLike` or [`ethers.utils.SigningKey`](https://docs.ethers.org/v5/api/utils/signing-key/#SigningKey) | The private key of the Ethereum account. | -| `providerL2?` | [`Provider`](/sdk/js/ethers/v5/providers#provider) | A ZKsync node provider. Needed for interaction with ZKsync (optional). | -| `providerL1?` | [`ethers.providers.Provider`](https://docs.ethers.org/v5/api/providers/provider/#Provider) | An Ethereum node provider. Needed for interaction with L1 (optional). | +| `providerL2?` | [`Provider`](/sdk/js/ethers/v5/providers#provider) | A ZKsync node provider. Needed for interaction with ZKsync. | +| `providerL1?` | [`ethers.providers.Provider`](https://docs.ethers.org/v5/api/providers/provider/#Provider) | An Ethereum node provider. Needed for interaction with L1. | ```ts constructor (privateKey: ethers.utils.BytesLike | ethers.utils.SigningKey, @@ -57,8 +58,8 @@ Creates a `Wallet` with the `provider` as L1 provider and a private key that is | Parameter | Type | Description | | ----------- | ------------------ | ----------------------------------------------------------------------- | | `mnemonic` | `string` | The mnemonic of the private key. | -| `path?` | `string` | If path is not specified, the Ethereum default path is used (optional). | -| `wordlist?` | `ethers.Worldlist` | If wordlist is not specified, the English Wordlist is used (optional). | +| `path?` | `string` | If path is not specified, the Ethereum default path is used. | +| `wordlist?` | `ethers.Worldlist` | If wordlist is not specified, the English Wordlist is used. | ```ts static fromMnemonic(mnemonic: string, path?: string, wordlist?: ethers.Wordlist) @@ -84,7 +85,7 @@ Creates a `Wallet` from encrypted `json` file using provided `password`. | ----------- | -------------------------- | -------------------------------------------------------------------------------------------------------------- | | `json` | `string` | Encrypted json file. | | `password` | `string` or `ethers.Bytes` | Password for encrypted json file. | -| `callback?` | `ProgressCallback` | If callback is provided, it is called periodically during decryption so that any UI can be updated (optional). | +| `callback?` | `ProgressCallback` | If callback is provided, it is called periodically during decryption so that any UI can be updated. | ```ts static async fromEncryptedJsonSync(json: string, password?: string | ethers.Bytes) @@ -150,6 +151,10 @@ const provider = Provider.getDefaultProvider(types.Network.Sepolia); const wallet = unconnectedWallet.connect(provider); ``` +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + It is possible to chain `connect` and `connectToL1` methods: ```ts @@ -320,7 +325,7 @@ Returns the amount of the token the `Wallet` has. | Parameter | Type | Description | | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------- | -| `token?` | `Address` | The address of the token. ETH by default (optional). | +| `token?` | `Address` | The address of the token. ETH by default. | | `blockTag` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts @@ -352,8 +357,8 @@ Returns the amount of the token the `Wallet` has on Ethereum. | Parameter | Type | Description | | ----------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | -| `token?` | `Address` | The address of the token. ETH by default (optional). | -| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `token?` | `Address` | The address of the token. ETH by default. | +| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getBalanceL1(token?: Address, blockTag?: BlockTag): Promise @@ -407,7 +412,7 @@ Returns account's nonce number. | Parameter | Type | Description | | ----------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | -| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getNonce(blockTag?: BlockTag): Promise @@ -627,9 +632,9 @@ For convenience, the `Wallet` class has `transfer` method, which can transfer | ------------------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `transaction.to` | `Address` | The address of the recipient. | | `transaction.amount` | `BigNumberish` | The amount of the token to transfer. | -| `transaction.token?` | `Address` | The address of the token. `ETH` by default (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.token?` | `Address` | The address of the token. `ETH` by default. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async transfer(transaction: { @@ -755,8 +760,8 @@ Returns the amount of approved tokens for a specific L1 bridge. | Parameter | Type | Description | | ---------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | -| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge` (optional). | -| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge`. | +| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getAllowanceL1( @@ -792,7 +797,7 @@ Bridging ERC20 tokens from Ethereum requires approving the tokens to the ZKsync | ------------ | ------------------- | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | | `amount` | `BigNumberish` | The amount of the token to be approved. | -| `overrides?` | `ethers.Overrides?` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `overrides?` | `ethers.Overrides?` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async approveERC20( @@ -829,8 +834,8 @@ Returns base cost for L2 transaction. | Name | Type | Description | | --------------------------- | -------------- | ------------------------------------------------------------------------------------------------- | | `params.gasLimit` | `BigNumberish` | The `gasLimit` for the L2 contract call. | -| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call (optional). | +| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call. | ```ts async getBaseCost(params: { @@ -1039,7 +1044,8 @@ specified L1 bridge (default one or the one defined in `transaction.bridgeAddres In this case, depending on is the chain ETH-based or not `transaction.approveERC20` or `transaction.approveBaseERC20` can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge, token approval will be skipped. -To check the amount of approved tokens for a specific bridge, use the [`allowanceL1`](#getallowancel1) method. +To check the amount of approved tokens for a specific bridge, use +the [`allowanceL1`](/sdk/js/ethers/v5/accounts#getallowancel1) method. #### Inputs @@ -1047,18 +1053,18 @@ To check the amount of approved tokens for a specific bridge, use the [`allowanc |-------------------------------------| ------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveBaseOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveBaseOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | ```ts async deposit(transaction: { @@ -1208,14 +1214,14 @@ Returns populated deposit transaction. | -------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getDepositTx(transaction: { @@ -1262,14 +1268,14 @@ Gas of approving ERC20 token is not included in estimation. | -------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasDeposit(transaction: @@ -1315,11 +1321,11 @@ Retrieves the full needed ETH fee for the deposit. Returns the L1 fee and the L2 | Parameter | Type | Description | | -------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getFullRequiredDepositFee(transaction: { @@ -1395,10 +1401,10 @@ account on L2 network to the target account on L1 network. | ------------------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to withdraw. | -| `transaction.to?` | `Address` | The address of the recipient on L1 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address of the recipient on L1. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async withdraw(transaction: { @@ -1504,7 +1510,7 @@ Proves the inclusion of the L2 -> L1 withdrawal message. | Name | Type | Description | | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | ```ts async finalizeWithdrawal(withdrawalHash: BytesLike, index: number = 0): Promise @@ -1535,7 +1541,7 @@ Returns weather the withdrawal transaction is finalized on the L1 network. | Name | Type | Description | | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | ```ts async isWithdrawalFinalized(withdrawalHash: BytesLike, index: number = 0): Promise @@ -1567,7 +1573,7 @@ from the withdrawal transaction's log on the L1 network. | Name | Type | Description | | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | ```ts async finalizeWithdrawalParams(withdrawalHash: BytesLike, index: number = 0): Promise @@ -1600,13 +1606,13 @@ Existing allowance for the bridge is not checked; allowance is calculated solely |----------------------------------| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteAllowanceParams(transaction: { @@ -1659,14 +1665,14 @@ Request execution of L2 transaction from L1. |----------------------------------| ------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async requestExecute(transaction: { @@ -1745,14 +1751,14 @@ Returns populated request execute transaction. | -------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteTx(transaction: { @@ -1829,14 +1835,14 @@ Estimates the amount of gas required for a request execute transaction. | -------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasRequestExecute(transaction: { @@ -1912,7 +1918,7 @@ Returns the transaction confirmation data that is part of `L2->L1` message. | Name | Type | Description | |----------| ----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `txHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0. | ```ts async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ @@ -2167,8 +2173,8 @@ But for convenience, the `Wallet` class has `transfer` method, which can transfe | `transaction.to` | `Address` | The address of the recipient. | | `transaction.amount` | `BigNumberish` | The amount of the token to transfer. | | `transaction.token?` | `Address` | The address of the token. `ETH` by default. | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async transfer(transaction: { @@ -2300,10 +2306,10 @@ account on L2 network to the target account on L1 network. | ------------------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to withdraw. | -| `transaction.to?` | `Address` | The address of the recipient on L1 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address of the recipient on L1. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async withdraw(transaction: { @@ -2570,8 +2576,8 @@ Returns the amount of approved tokens for a specific L1 bridge. | Parameter | Type | Description | | ---------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | -| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge` (optional). | -| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge`. | +| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getAllowanceL1( @@ -2604,7 +2610,7 @@ Bridging ERC20 tokens from Ethereum requires approving the tokens to the ZKsync | ------------ | ------------------- | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | | `amount` | `BigNumberish` | The amount of the token to be approved. | -| `overrides?` | `ethers.Overrides?` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `overrides?` | `ethers.Overrides?` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async approveERC20( @@ -2636,8 +2642,8 @@ Returns base cost for L2 transaction. | Name | Type | Description | | --------------------------- | -------------- | ------------------------------------------------------------------------------------------------- | | `params.gasLimit` | `BigNumberish` | The `gasLimit` for the L2 contract call. | -| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call (optional). | +| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call. | ```ts async getBaseCost(params: { @@ -2841,7 +2847,8 @@ specified L1 bridge (default one or the one defined in `transaction.bridgeAddres In this case, depending on is the chain ETH-based or not `transaction.approveERC20` or `transaction.approveBaseERC20` can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge, token approval will be skipped. -To check the amount of approved tokens for a specific bridge, use the [`allowanceL1`](#getallowancel1) method. +To check the amount of approved tokens for a specific bridge, use +the [`allowanceL1`](/sdk/js/ethers/v5/accounts#getallowancel1) method. #### Inputs @@ -2849,18 +2856,18 @@ To check the amount of approved tokens for a specific bridge, use the [`allowanc |-------------------------------------| ------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveBaseOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveBaseOverrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | ```ts async deposit(transaction: { @@ -2990,14 +2997,14 @@ Returns populated deposit transaction. | -------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getDepositTx(transaction: { @@ -3041,14 +3048,14 @@ Gas of approving ERC20 token is not included in estimation. | -------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasDeposit(transaction: @@ -3091,11 +3098,11 @@ Retrieves the full needed ETH fee for the deposit. Returns the L1 fee and the L2 | Parameter | Type | Description | | -------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getFullRequiredDepositFee(transaction: { @@ -3163,7 +3170,7 @@ Proves the inclusion of the L2 -> L1 withdrawal message. | Name | Type | Description | | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | ```ts async finalizeWithdrawal(withdrawalHash: BytesLike, index: number = 0): Promise @@ -3191,7 +3198,7 @@ Returns weather the withdrawal transaction is finalized on the L1 network. | Name | Type | Description | | ---------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0) (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0). | ```ts async isWithdrawalFinalized(withdrawalHash: BytesLike, index: number = 0): Promise @@ -3220,7 +3227,7 @@ from the withdrawal transaction's log on the L1 network. | Name | Type | Description | | ---------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0) (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0). | ```ts async finalizeWithdrawalParams(withdrawalHash: BytesLike, index: number = 0): Promise @@ -3250,13 +3257,13 @@ Existing allowance for the bridge is not checked; allowance is calculated solely |----------------------------------| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteAllowanceParams(transaction: { @@ -3307,16 +3314,16 @@ Request execution of L2 transaction from L1. | Name | Type | Description | | -------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `transaction.contractAddress` | `Address` | The L2 contract to be called (optional). | -| `transaction.calldata` | `BytesLike` | The input of the L2 transaction (optional). | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.contractAddress?` | `Address` | The L2 contract to be called. | +| `transaction.calldata?` | `BytesLike` | The input of the L2 transaction. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts requestExecute(transaction: { @@ -3357,16 +3364,16 @@ Returns populated deposit transaction. | Name | Type | Description | | -------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `transaction.contractAddress` | `Address` | The L2 contract to be called (optional). | -| `transaction.calldata` | `BytesLike` | The input of the L2 transaction (optional). | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.contractAddress?` | `Address` | The L2 contract to be called. | +| `transaction.calldata?` | `BytesLike` | The input of the L2 transaction. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteTx(transaction: { @@ -3407,16 +3414,16 @@ Estimates the amount of gas required for a request execute transaction. | Name | Type | Description | | -------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `transaction.contractAddress` | `Address` | The L2 contract to be called (optional). | -| `transaction.calldata` | `BytesLike` | The input of the L2 transaction (optional). | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.contractAddress?` | `Address` | The L2 contract to be called. | +| `transaction.calldata?` | `BytesLike` | The input of the L2 transaction. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasRequestExecute(transaction: { @@ -3460,7 +3467,7 @@ Returns the transaction confirmation data that is part of `L2->L1` message. | Name | Type | Description | |----------| ----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `txHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0. | ```ts async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ @@ -3662,7 +3669,7 @@ Get the number of transactions ever sent for account, which is used as the `nonc | Parameter | Type | Description | | ----------- | ---------- | ----------------------------------------------- | -| `blockTag?` | `BlockTag` | The block tag to get the balance at (optional). | +| `blockTag?` | `BlockTag` | The block tag to get the balance at. | ```ts async getNonce(blockTag?: BlockTag): Promise @@ -3869,10 +3876,10 @@ account on L2 network to the target account on L1 network. | ------------------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to withdraw. | -| `transaction.to?` | `Address` | The address of the recipient on L1 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address of the recipient on L1. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async withdraw(transaction: { @@ -3944,9 +3951,9 @@ Transfer ETH or any ERC20 token within the same interface. | ------------------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | | `transaction.to` | `Address` | The address of the recipient. | | `transaction.amount` | `BigNumberish` | The amount of the token to transfer. | -| `transaction.token?` | `Address` | The address of the token. `ETH` by default (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.token?` | `Address` | The address of the token. `ETH` by default. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v5/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async transfer(transaction: { diff --git a/content/sdk/10.js/00.ethers/10.v5/05.accounts-l1-l2.md b/content/sdk/10.js/00.ethers/10.v5/05.accounts-l1-l2.md index 24b95ee9..c591b9fc 100644 --- a/content/sdk/10.js/00.ethers/10.v5/05.accounts-l1-l2.md +++ b/content/sdk/10.js/00.ethers/10.v5/05.accounts-l1-l2.md @@ -1,46 +1,47 @@ --- title: Accounts | L1<->L2 Transactions -description: +description: Methods to facilitate transactions between L1 and L2 networks using zksync-ethers. +tags: ["zksync", "account management", "wallet creation", "transaction signing", "cryptocurrency", "ethereum", "l1 to l2 transactions"] --- -This section explores the methods which allow the [account](/sdk/js/ethers/v5/accounts) to send transactions -among both L1 to L2 networks. +Learn how to send transactions between L1 and L2 networks using the `zksync-ethers` library. -If you want some background on how L1<->L2 interaction works on ZKsync, go through the -[introduction](https://docs.zksync.io/build/developer-reference/l1-l2-interop.html). +If you need background information on how L1<->L2 interactions work on ZKsync, check out the [Developer Reference](https://docs.zksync.io/build/developer-reference/l1-l2-interop.html). ## Deposit -`Wallet` and `L1Signer` objects provide a deposit workflow. For more information, -please refer to the method specification [`Deposit`](/sdk/js/ethers/v5/accounts#deposit). +`Wallet` and `L1Signer` objects allow you to deposit funds from L1 to L2. -For a complete example of how to execute the deposit workflow, take a look at the following: -[Deposit ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/01_deposit.ts). +- **More Information**: See the method specification [`Deposit`](/sdk/js/ethers/v5/accounts#deposit). +- **Example**: [Deposit ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/01_deposit.ts). ## Request execute -`Wallet` and `L1Signer` objects provide an option to request execution of L2 transaction from L1. -For more information, please refer to the method specification [`requestExecute`](/sdk/js/ethers/v5/accounts#requestexecute). +`Wallet` and `L1Signer` objects let you request the execution of an L2 transaction from L1. + +- **More Information**: See the method specification [`requestExecute`](/sdk/js/ethers/v5/accounts#requestexecute). ## Base cost -`Wallet` and `L1Signer` objects provide an option to calculate base cost for L2 transaction. -For more information, please refer to the method specification [`getBaseCost`](/sdk/js/ethers/v5/accounts#getbasecost). +`Wallet` and `L1Signer` objects can calculate the base cost for an L2 transaction. + +- **More Information**: See the method specification [`getBaseCost`](/sdk/js/ethers/v5/accounts#getbasecost). ## Claim failed deposit -`Wallet` and `L1Signer` objects provide a claim fail deposit workflow. -For more information, please refer to the method specification [`claimFailedDeposit`](/sdk/js/ethers/v5/accounts#claimfaileddeposit). +`Wallet` and `L1Signer` objects provide a way to claim a failed deposit. + +- **More Information**: See the method specification [`claimFailedDeposit`](/sdk/js/ethers/v5/accounts#claimfaileddeposit). ## Finalize withdraw -`Wallet` and `L1Signer` objects provide a finalize withdraw workflow. -For more information, please refer to the method specification [`finalizeWithdrawal`](/sdk/js/ethers/v5/accounts#finalizewithdrawal). +`Wallet` and `L1Signer` objects allow you to finalize a withdrawal from L2 to L1. + +- **More Information**: See the method specification [`finalizeWithdrawal`](/sdk/js/ethers/v5/accounts#finalizewithdrawal). ## Withdrawal -`Wallet` and `Signer` objects provide a withdrawal workflow. -For more information, please refer to the method specification [`Withdraw`](/sdk/js/ethers/v5/accounts#withdraw). +`Wallet` and `Signer` objects enable you to withdraw funds from L2 to L1. -For a complete example of how to execute the deposit workflow, take a look at the following: -[Withdraw ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/04_withdraw.ts). +- **More Information**: See the method specification [`Withdraw`](/sdk/js/ethers/v5/accounts#withdraw). +- **Example**: [Withdraw ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/04_withdraw.ts). diff --git a/content/sdk/10.js/00.ethers/10.v5/06.contracts.md b/content/sdk/10.js/00.ethers/10.v5/06.contracts.md index f521fd71..bff604e3 100644 --- a/content/sdk/10.js/00.ethers/10.v5/06.contracts.md +++ b/content/sdk/10.js/00.ethers/10.v5/06.contracts.md @@ -1,6 +1,7 @@ --- title: Contracts -description: +description: Using contracts with the zksync-ethers library. +tags: ["zksync", "contracts", "smart contracts", "ethereum", "contractfactory", "erc20 tokens"] --- `zksync-ethers` does not implement any new `Contract` class, since `ethers.Contract` fully works out of the box. @@ -10,4 +11,4 @@ Since deploying smart contracts on ZKsync has some differences from deploying on a specific `ContractFactory` method. It supports the same interface as `ethers.ContractFactory`. In order to pay for smart contract interactions in ERC20 tokens, `customData` override should be used. -You can read more about accessing ZKsync features in [the features chapter](/sdk/js/ethers/v5/features). +You can read more about accessing ZKsync features in [ZKsync Era Features](/sdk/js/ethers/v5/features). diff --git a/content/sdk/10.js/00.ethers/10.v5/07.utils.md b/content/sdk/10.js/00.ethers/10.v5/07.utils.md index 22579b40..665d0431 100644 --- a/content/sdk/10.js/00.ethers/10.v5/07.utils.md +++ b/content/sdk/10.js/00.ethers/10.v5/07.utils.md @@ -1,6 +1,7 @@ --- title: Utilities -description: +description: Essential utilities for building on ZKsync Era. +tags: ["zksync", "utilities", "ethereum", "smart contracts"] --- The [utilities library](https://github.com/zksync-sdk/zksync-ethers/blob/ethers-v5/src/utils.ts) contains essential @@ -175,7 +176,7 @@ const ETH_ADDRESS_IN_CONTRACTS: Address = '0x00000000000000000000000000000000000 #### ETH token alias on ZkSync Era ::callout{icon="i-heroicons-exclamation-triangle" color="amber"} -Deprecated in favor of [L2_BASE_TOKEN_ADDRESS](#l2-base-token) +Deprecated in favor of [L2_BASE_TOKEN_ADDRESS](/sdk/js/ethers/v5/utils#l2-base-token) :: ```ts @@ -269,7 +270,9 @@ const l2ContractAddress = utils.applyL1ToL2Alias(l1ContractAddress); // l2ContractAddress = "0x813A42B8205E5DedCd3374e5f4419843ADa77FFC" ``` -See also [`undol1tol2alias`](#undol1tol2alias). +::callout +See also [`undol1tol2alias`](/sdk/js/ethers/v5/utils#undol1tol2alias). +:: ### `checkBaseCost` @@ -362,7 +365,7 @@ Returns the hash of an EIP712 transaction. | Parameter | Type | Description | | --------------- | --------------------------------------------------- | ---------------------------------------------- | | `transaction` | `any` | EIP-712 transaction. | -| `ethSignature?` | [`EthereumSignature`](/sdk/js/ethers/v5/types#ethereumsignature) | ECDSA signature of the transaction (optional). | +| `ethSignature?` | [`EthereumSignature`](/sdk/js/ethers/v5/types#ethereumsignature) | ECDSA signature of the transaction. | ```ts function eip712TxHash(transaction: any, ethSignature?: EthereumSignature): string; @@ -386,8 +389,8 @@ Check out the default bridges documentation. | `token` | `Address` | Token address. | | `amount` | `BigNumberish` | Deposit amount. | | `to` | `Address` | Recipient address. | -| `from?` | `Address` | Sender address (optional). | -| `gasPerPubdataByte?` | `BigNumberish` | Current gas per byte of pubdata (optional). | +| `from?` | `Address` | Sender address. | +| `gasPerPubdataByte?` | `BigNumberish` | Current gas per byte of pubdata. | ```ts async function estimateDefaultBridgeDepositL2Gas( @@ -531,7 +534,7 @@ utils.isAddressEq("0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", "0x36615cf349d7f Validates signatures from non-contract account addresses (EOA). Provides similar functionality in `ethers.js` but returns `true` if the validation process succeeds, otherwise returns `false`. -Called from [`isSignatureCorrect`](#issignaturecorrect) for non-contract account addresses. +Called from [`isSignatureCorrect`](/sdk/js/ethers/v5/utils#issignaturecorrect) for non-contract account addresses. #### Inputs @@ -562,12 +565,19 @@ const isValidSignature = await utils.isECDSASignatureCorrect(ADDRESS, message, s // isValidSignature = true ``` -See also [`isMessageSignatureCorrect()`](#ismessagesignaturecorrect) and -[`isTypedDataSignatureCorrect()`](#istypeddatasignaturecorrect) to validate signatures. +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + +::callout +See also [`isMessageSignatureCorrect()`](/sdk/js/ethers/v5/utils#ismessagesignaturecorrect) and +[`isTypedDataSignatureCorrect()`](/sdk/js/ethers/v5/utils#istypeddatasignaturecorrect) to validate signatures. +:: ### `isEIP1271SignatureCorrect` -Called from [`isSignatureCorrect`](#issignaturecorrect) for contract account addresses, the function returns true if +Called from [`isSignatureCorrect`](/sdk/js/ethers/v5/utils#ismessagesignaturecorrect) for contract account +addresses, the function returns true if the validation process results in the `EIP1271_MAGIC_VALUE`. #### Inputs @@ -583,8 +593,10 @@ the validation process results in the `EIP1271_MAGIC_VALUE`. async function isEIP1271SignatureCorrect(provider: Provider, address: string, msgHash: string, signature: SignatureLike): Promise; ``` -See also [`isMessageSignatureCorrect()`](#ismessagesignaturecorrect) -and [`isTypedDataSignatureCorrect()`](#istypeddatasignaturecorrect) to validate signatures. +::callout +See also [`isMessageSignatureCorrect()`](/sdk/js/ethers/v5/utils#ismessagesignaturecorrect) +and [`isTypedDataSignatureCorrect()`](/sdk/js/ethers/v5/utils#istypeddatasignaturecorrect) to validate signatures. +:: ### `isETH` @@ -644,8 +656,9 @@ const isValidSignature = await utils.isMessageSignatureCorrect(provider, ADDRESS ### `isSignatureCorrect` -Called from [`isMessageSignatureCorrect`](#ismessagesignaturecorrect) -and [`isTypedDataSignatureCorrect`](#istypeddatasignaturecorrect). Returns true if account abstraction EIP712 +Called from [`isMessageSignatureCorrect`](/sdk/js/ethers/v5/utils#ismessagesignaturecorrect) +and [`isTypedDataSignatureCorrect`](/sdk/js/ethers/v5/utils#istypeddatasignaturecorrect). Returns true if +account abstraction EIP712 signature is correct. #### Inputs @@ -775,7 +788,7 @@ Serializes an EIP712 transaction and include a signature if is provided. Throws | Parameter | Type | Description | | ------------- | -------------------- | ---------------------------------------------------------------------- | | `transaction` | `TransactionRequest` | Transaction that needs to be serialized. | -| `signature?` | `SignatureLike` | Ethers signature that needs to be included in transactions (optional). | +| `signature?` | `SignatureLike` | Ethers signature that needs to be included in transactions. | ```ts function serialize(transaction: ethers.providers.TransactionRequest, signature?: SignatureLike); @@ -844,4 +857,6 @@ const l1ContractAddress = utils.undoL1ToL2Alias(l2ContractAddress); // const l1ContractAddress = "0x702942B8205E5dEdCD3374E5f4419843adA76Eeb" ``` -See also [`applyl1tol2alias`](#applyl1tol2alias). +::callout +See also [`applyl1tol2alias`](/sdk/js/ethers/v5/utils#applyl1tol2alias). +:: diff --git a/content/sdk/10.js/00.ethers/10.v5/08.paymaster-utils.md b/content/sdk/10.js/00.ethers/10.v5/08.paymaster-utils.md index 446aa29a..c441f151 100644 --- a/content/sdk/10.js/00.ethers/10.v5/08.paymaster-utils.md +++ b/content/sdk/10.js/00.ethers/10.v5/08.paymaster-utils.md @@ -1,6 +1,7 @@ --- title: Paymaster Utilities -description: +description: Essential utilities for using paymasters on ZKsync Era. +tags: ["zksync", "paymasters", "ethereum", "gas fees", "smart contracts"] --- The [paymaster utilities library](https://github.com/zksync-sdk/zksync-ethers/blob/main/src/paymaster-utils.ts) @@ -8,8 +9,7 @@ contains essential utilities for using paymasters on ZKsync Era. ## Contract interfaces -Constant ABI definition for -the [Paymaster Flow Interface](https://github.com/matter-labs/era-contracts/blob/583cb674a2b942dda34e9f46edb5a9f5b696b90a/l2-contracts/contracts/interfaces/IPaymasterFlow.sol). +Constant ABI definition for the [Paymaster Flow Interface](https://github.com/matter-labs/era-contracts/blob/583cb674a2b942dda34e9f46edb5a9f5b696b90a/l2-contracts/contracts/interfaces/IPaymasterFlow.sol). ```ts const PAYMASTER_FLOW_ABI = new ethers.Interface(IPaymasterFlowABI); @@ -33,7 +33,7 @@ function getApprovalBasedPaymasterInput(paymasterInput: ApprovalBasedPaymasterIn ### `getGeneralPaymasterInput` -As above but for general-based paymaster. +Returns encoded input for a general-based paymaster. #### Inputs @@ -47,8 +47,7 @@ function getGeneralPaymasterInput(paymasterInput: GeneralPaymasterInput): BytesL ### `getPaymasterParams` -Returns a correctly-formed `paymasterParams` object for common -[paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction/paymasters#built-in-paymaster-flows). +Returns a correctly-formed `paymasterParams` object for common [paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction/paymasters#built-in-paymaster-flows). #### Inputs diff --git a/content/sdk/10.js/00.ethers/10.v5/09.smart-account-utils.md b/content/sdk/10.js/00.ethers/10.v5/09.smart-account-utils.md index 688828b2..866a3337 100644 --- a/content/sdk/10.js/00.ethers/10.v5/09.smart-account-utils.md +++ b/content/sdk/10.js/00.ethers/10.v5/09.smart-account-utils.md @@ -1,6 +1,7 @@ --- title: Smart Account Utilities -description: +description: Utilities for signing transactions with ECDSA private keys. +tags: ["zksync", "ecdsa", "smart contracts", "ethereum", "transaction signing"] --- ## Functions @@ -75,11 +76,14 @@ const typedDataHash = ethers.utils._TypedDataEncoder.hash( const signature = await utils.signPayloadWithECDSA(typedDataHash, PRIVATE_KEY); ``` +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + ### `signPayloadWithMultipleECDSA` -Signs the `payload` using multiple ECDSA private keys. -The signature is generated by concatenating signatures created by signing with each key individually. -The length of the resulting signature should be `secrets.length * 65 + 2`. +Signs the `payload` using multiple ECDSA private keys. The signature is generated by concatenating signatures +created by signing with each key individually. The length of the resulting signature should be `secrets.length * 65 + 2`. #### Inputs @@ -150,14 +154,14 @@ const typedDataHash = ethers.utils._TypedDataEncoder.hash( const signature = await utils.signPayloadWithMultipleECDSA(typedDataHash, [PRIVATE_KEY1, PRIVATE_KEY2]); ``` -## `populateTransactionECDSA` +### `populateTransactionECDSA` Populates missing properties meant for signing using an ECDSA private key: - Populates `from` using the address derived from the ECDSA private key. - Populates `nonce` via `provider.getTransactionCount(tx.from, "pending")`. - Populates `gasLimit` via `provider.estimateGas(tx)`. If `tx.from` is not EOA, the estimation is done with address - derived from the ECDSA private key. +derived from the ECDSA private key. - Populates `chainId` via `provider.getNetwork()`. - Populates `type` with `utils.EIP712_TX_TYPE`. - Populates `value` by converting to `bigint` if set, otherwise to `0n`. @@ -196,11 +200,11 @@ const populatedTx = await utils.populateTransactionECDSA( ); ``` -## `populateTransactionMultisigECDSA` +### `populateTransactionMultisigECDSA` -Populates missing properties meant for signing using multiple ECDSA private keys. -It uses [`populateTransactionECDSA`](#populatetransactionecdsa), -where the address of the first ECDSA key is set as the `secret` argument. +Populates missing properties meant for signing using multiple ECDSA private keys. It +uses [`populateTransactionECDSA`](#populatetransactionecdsa), where the address of the first ECDSA key is +set as the `secret` argument. #### Inputs diff --git a/content/sdk/10.js/00.ethers/10.v5/10.types.md b/content/sdk/10.js/00.ethers/10.v5/10.types.md index ef8a011d..757e8b10 100644 --- a/content/sdk/10.js/00.ethers/10.v5/10.types.md +++ b/content/sdk/10.js/00.ethers/10.v5/10.types.md @@ -1,23 +1,30 @@ --- title: Types and Interfaces -description: +description: Definitions and interfaces used in ZKsync Era. +tags: ["zksync", "types", "interfaces", "ethereum", "blockchain"] --- ## `AccountAbstractionVersion` Enumerated list of account abstraction versions. +::collapsible + - None = `0` - Used for contracts that are not accounts. - Version1 = `1` - Used for contracts that are accounts. +:: ## `AccountNonceOrdering` Enumerated list of account nonce ordering formats. +::collapsible + - Sequential = `0` - Nonces should be ordered in the same way as in externally owned accounts (EOAs). This means, for instance, that the operator will always wait for a transaction with nonce `X` before processing a transaction with nonce `X+1`. - Arbitrary = `1` - Nonces can be ordered in arbitrary order. +:: ## `Address` @@ -27,10 +34,13 @@ Enumerated list of account nonce ordering formats. Interface representation of approval based paymaster input. +::collapsible + - `type`: `'ApprovalBased'` - The type of the paymaster input. - `token`: `Address` - The address of the token to be approved. - `minimalAllowance`: `BigNumber` - The minimum allowance required for the token approval. - `innerInput`: `BytesLike`- The additional input data.; +:: ## `BalancesMap` @@ -42,6 +52,8 @@ Type defining a map object containing accounts and their balances. Interface representation of batch details. +::collapsible + - `number`: `number` - L1 batch number. - `timestamp`: `number`- Unix timestamp when the batch was processed. - `l1TxCount`: `number` - Number of L1 transactions included in the batch. @@ -57,6 +69,7 @@ Interface representation of batch details. - `l1GasPrice`: `number` - L1 gas price at the time of the block's execution. - `l2FairGasPrice`: `number` - Fair gas price on L2 at the time of the block's execution. - `baseSystemContractsHashes`: `object` - Hashes of the base system contracts involved in the batch. +:: ## `Block` @@ -64,13 +77,18 @@ Interface representation of block that extends the Ethers [`providers.Block`](https://docs.ethers.org/v5/api/providers/types/#providers-Block) definition with additional fields. +::collapsible + - `l1BatchNumber`: `number` - The batch number on L1. - `l1BatchTimestamp`: `number` - The timestamp of the batch on L1. +:: ## `BlockDetails` Interface representation of block details. +::collapsible + - `number`: `number` - Number of the block. - `timestamp`: `number` - Unix timestamp when the block was committed. - `l1BatchNumber`: `number` - Corresponding L1 batch number. @@ -89,11 +107,14 @@ Interface representation of block details. - `baseSystemContractsHashes`: `object` - A collection of hashes for the base system contracts involved in the block. - `operatorAddress`: `string` - Address of the operator who committed the block. - `protocolVersion`: `string` - version of the ZKsync protocol the block was committed under. +:: ## `BlockTag` Pipe-delimited list of block labels that includes block number in binary and hex plus block statuses. +::collapsible + - `number` - `string` // hex representation of block number - `committed` @@ -101,81 +122,108 @@ Pipe-delimited list of block labels that includes block number in binary and hex - `latest` - `earliest` - `pending` +:: ## `BlockWithTransaction` Interface representation of block with transaction(s) that extends the Ethers `BlockWithTransactions` definition with additional fields. +::collapsible + - `l1BatchNumber`: `number` - The batch number on L1. - `l1BatchTimestamp`: `number` - The timestamp of the batch on L1. - `transactions`: `Array` - The transactions that are part of the block. +:: ## `ContractAccountInfo` Interface representation for contract account information containing information on account abstraction version and nonce ordering format. +::collapsible + - `supportedAAVersion`: `AccountAbstractionVersion` - The supported account abstraction version. - `nonceOrdering`: `AccountNonceOrdering` - The nonce ordering format. +:: ## `DeploymentInfo` Interface representation of deployment information. +::collapsible + - `sender`: `Address` - The account responsible for deployment. - `bytecodeHash`: `string` - The hash of the contract/account bytecode. - `deployedAddress`: `Address` - The deployed address of the contract/address. +:: ## `DeploymentType` Pipe-delimited choice of two deployment types that support all `create2` variants. +::collapsible + - `create` - `createAccount` +:: ## `Eip712Meta` Contains EIP712 transaction metadata. +::collapsible + - `gasPerPubdata?`: `BigNumberish` - The maximum amount of gas the user is willing to pay for a single byte of pubdata. - `factoryDeps?`: `BytesLike[]` - An array of bytes containing the bytecode of the contract being deployed and any related contracts it can deploy. - `customSignature?`: `BytesLike` - Custom signature used for cases where the signer's account is not an EOA. - `paymasterParams?`: `PaymasterParams` - Parameters for configuring the custom paymaster for the transaction. +:: ## `EthereumSignature` Interface representation of an Ethereum signature. +::collapsible + - `v`: `number` - The recovery id. - `r`: `BytesLike` - The "r" value of the signature. - `s`: `BytesLike` - The "s" value of the signature. +:: ## `EventFilter` Interface representation of event filter which allows efficiently filtering logs (also known as events) using bloom filters included within blocks. +::collapsible + - `topics?`: `Array | null>` - An array representing the structure to define bloom-filter queries. - `address?`: `Address | Array
` - The address or addresses from which logs are filtered. - `fromBlock?`: `BlockTag` - The block number or block tag representing the starting block for filtering logs. - `toBlock?`: `BlockTag` - The block number or block tag representing the ending block for filtering logs. - `blockHash?`: `string` - The hash of the block from which logs are filtered. +:: ## `Fee` Interface representation of transaction fee parameters. +::collapsible + - `gasLimit`: `BigNumber` - The maximum amount of gas that can be used. - `gasPerPubdataLimit`: `BigNumber` - The gas limit per unit of public data. - `maxPriorityFeePerGas`: `BigNumber` - The maximum priority fee per unit of gas to incentivize miners. - `maxFeePerGas`: `BigNumber` - The maximum fee per unit of gas that the sender is willing to pay. +:: ## `FeeParams` Interface representation of fee parameter configuration. +::collapsible + - `V2`: - Fee parameter configuration for the current version of the ZKsync protocol. - `config`: - Settings related to transaction fee computation. - `minimal_l2_gas_price`: `BigNumber` - Minimal gas price on L2. @@ -186,10 +234,12 @@ Interface representation of fee parameter configuration. - `max_pubdata_per_batch`: `BigNumber` - Maximum amount of public data allowed per batch. - `l1_gas_price`: `BigNumber` - Current L1 gas price. - `l1_pubdata_price`: `BigNumber` - Price of storing public data on L1. +:: ## `FinalizeWithdrawalParams` Interface representation of finalize withdrawal parameters. +::collapsible - `l1BatchNumber`: `number | null` - The L2 batch number where the withdrawal was processed. - `l2MessageIndex`: `number` - The position in the L2 logs Merkle tree of the l2Log that was sent with the message. @@ -197,10 +247,12 @@ Interface representation of finalize withdrawal parameters. - `message`: `any` - The L2 withdraw data, stored in an L2 -> L1 message. - `sender`: `string` - The L2 address which sent the log. - `proof`: `string[]` - The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization. +:: ## `FullDepositFee` Interface representation of full deposit fee containing fees for both L1 and L2 transactions. +::collapsible - `maxFeePerGas?`: `BigNumber` - The maximum fee per gas for L1 transaction. - `maxPriorityFeePerGas?`: `BigNumber` - The maximum priority fee per gas for L1 transaction. @@ -208,17 +260,22 @@ Interface representation of full deposit fee containing fees for both L1 and L2 - `baseCost`: `BigNumber` - The base cost of the deposit transaction on L2. - `l1GasLimit`: `BigNumber` - The gas limit for L1 transaction. - `l2GasLimit`: `BigNumber` - The gas limit for L2 transaction. +:: ## `GeneralPaymasterInput` Interface representation of general paymaster input. +::collapsible + - `type`: `'General'` - The type of the paymaster input. - `innerInput`: `BytesLike` - The additional input data. +:: ## `L2ToL1Log` Interface representation of a layer 2 to layer 1 transaction log. +::collapsible - `blockNumber`: `number` - The block number. - `blockHash`: `string` - The block hash. @@ -234,6 +291,7 @@ Interface representation of a layer 2 to layer 1 transaction log. - `value`: `string` - The 32 bytes of information that was sent in the log. - `transactionHash`: `string` - The transaction hash. - `logIndex`: `number` - The log index. +:: ## `Log` @@ -247,53 +305,70 @@ and supplies the layer 1 batch number. Interface representation of message proof. +::collapsible + - `id`: `number` - Identifier of the log within the transaction. - `proof`: `string[]` - Each element represents a piece of the proof for the specified log. - `root`: `string` - Root hash of the proof, anchoring it to a specific state in the blockchain. +:: ## `MessageProof` -::callout{icon="i-heroicons-exclamation-triangle" color="amber"} -Deprecated in favor of `[LogProof](#logproof)` -:: - Interface representation of message proof. +::collapsible - `id`: `number` - Identifier of the log within the transaction. - `proof`: `string[]` - Each element represents a piece of the proof for the specified log. - `root`: `string` - Root hash of the proof, anchoring it to a specific state in the blockchain. +:: + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +Deprecated in favor of `[LogProof](#logproof)` +:: ## `Network` Enumerated list of networks and their ids. +::collapsible + - Mainnet = `1` - Ropsten = `3` - Rinkeby = `4` - Sepolia = `6`, - localhost = `9`, - EraTestNode = `10`, +:: ## `PaymasterInput` Type definition for a paymaster input specified as either approval based or general. +::collapsible + - `ApprovalBasedPaymasterInput` | `GeneralPaymasterInput` +:: ## `PaymasterParams` Type defining a paymaster by address and the bytestream input. +::collapsible + - `paymaster`: `Address` - The address of the paymaster. - `paymasterInput`: `BytesLike` - The bytestream input for the paymaster. +:: ## `PayloadSigner` Signs various types of payloads, optionally using a some kind of secret. +::collapsible + - `payload`: `BytesLike` - The payload that needs to be sign. - `secret`: `any` - The secret used for signing the `payload`. - `provider` `null | Provider` - The provider is used to fetch data from the network if it is required for signing. +:: ## `PriorityOpResponse` @@ -307,31 +382,42 @@ including waiting for the specified number of confirmations. Enumerated list of priority operation tree types. +::collapsible + - Full = `0`, - Rollup = `1`, +:: ## `PriorityQueueType` Enumerated list of priority queue types. +::collapsible + - Deque = `0`, - HeapBuffer = `1`, - Heap = `2`, +:: ## `ProtocolVersion` Interface representation of protocol version. +::collapsible + - `version_id`: `number` - Protocol version ID. - `timestamp`: `number` - Unix timestamp of the version's activation. - `verification_keys_hashes`: `object` - Contains the hashes of various verification keys used in the protocol. - `base_system_contracts`: `object` - Addresses of the base system contracts. - `l2_system_upgrade_tx_hash`: `string | null` - Hash of the transaction used for the system upgrade, if any. +:: ## `RawBlockTransaction` Interface representation of raw block with transactions. +::collapsible + - `common_data`: - General information about the L2 transaction. - `L2`: - `nonce`: `number`; @@ -356,6 +442,7 @@ Interface representation of raw block with transactions. - `value`: `BigNumber`; - `received_timestamp_ms`: `number` - Timestamp when the transaction was received, in milliseconds. - `raw_bytes`: `string` - Raw bytes of the transaction as a hexadecimal string. +:: ## `Signature` @@ -365,15 +452,20 @@ Interface representation of raw block with transactions. Encapsulates the required input parameters for creating a signer for [`SmartAccount`](/sdk/js/ethers/v5/accounts#smartaccount). +::collapsible + - `address`: `string` - Address to which the `SmartAccount` is bound. - `secret`: `any` - Secret in any form that can be used for signing different payloads. - `payloadSigner`: `PayloadSigner` - Custom method for signing different payloads. - `transactionBuilder`: `TransactionBuilder` - Custom method for populating transaction requests. +:: ## `StorageProof` Interface representation of Merkle proofs for storage values. +::collapsible + - `address`: `string` - Account address associated with the storage proofs. - `storageProof` (Array): - Array of objects, each representing a storage proof for the requested keys. - `key`: `string` - Storage key for which the proof is provided. @@ -382,29 +474,38 @@ Interface representation of Merkle proofs for storage values. This index is used to help reconstruct the Merkle path during verification. - `proof`: `string[]` - An array of 32-byte hashes that constitute the Merkle path from the leaf node (representing the storage key-value pair) to the root of the Merkle tree. +:: ## `Token` Interface representation of bridged token. +::collapsible + - `l1Address`: `Address` - Token address on L1. - `l2Address`: `Address` - Token address on L2. - `name`: `string` - Token name. - `symbol`: `string` - Token symbol. - `decimals`: `number` - Token decimals. +:: ## `TransactionBuilder` Populates missing fields in a transaction with default values. +::collapsible + - `transaction`: `TransactionRequest` - The transaction that needs to be populated. - `secret`: `any` - The secret used for populating the transaction. - `provider`: `null | Provider` - The provider is used to fetch data from the network if it is required for signing. +:: ## `TransactionDetails` Interface representation of transaction details. +::collapsible + - `isL1Originated`: `boolean` - Indicates whether the transaction originated on Layer 1. - `status`: `string` - Current status of the transaction (e.g., verified). - `fee`: `BigNumberish` - Transaction fee. @@ -414,6 +515,7 @@ Interface representation of transaction details. - `ethCommitTxHash?`: `string` - Transaction hash of the commit operation. - `ethProveTxHash?`: `string` - Transaction hash of the proof submission. - `ethExecuteTxHash?`: `string` - Transaction hash of the execution. +:: ## `TransactionReceipt` @@ -421,10 +523,13 @@ Interface representation of transaction receipt that extends from Ethers [`providers.TransactionReceipt`](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt) with additional fields. +::collapsible + - `l1BatchNumber`: `number` - The batch number on the L1 network. - `l1BatchTxIndex`: `number` - The transaction index within the batch on the L1 network. - `logs`: `Array` - All logs included in the transaction receipt. - `l2ToL1Logs`: `Array` - The logs of L2 to L1 messages. +:: ## `TransactionRequest` @@ -440,24 +545,33 @@ Interface representation of transaction response that extends from Ethers [`providers.TransactionResponse`](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionResponse) with additional fields. +::collapsible + - `l1BatchNumber`: `number` - The batch number on the L1 network. - `l1BatchTxIndex`: `number` - The transaction index within the batch on the L1 network. - `wait()`: `Promise` - Waits for transaction to be mined. - `waitFinalize()`: `Promise` - Waits for transaction to be finalized. +:: ## `TransactionStatus` Enumerated list of transaction statuses. +::collapsible + - NotFound = `not-found` - Transaction not found. - Processing = `processing` - Transaction is processing. - Committed = `committed` - Transaction has been committed. - Finalized = `finalized` - Transaction has been finalized. +:: ## `TransactionWithDetailedOutput` Interface representation of transaction with detailed output. +::collapsible + - `transactionHash`: `string` - Transaction hash. - `storageLogs`: `Array` - Storage slots - `events`: `Array` - Generated events. +:: diff --git a/content/sdk/10.js/00.ethers/20.v6/01.features.md b/content/sdk/10.js/00.ethers/20.v6/01.features.md index 96576eaf..8c9716e1 100644 --- a/content/sdk/10.js/00.ethers/20.v6/01.features.md +++ b/content/sdk/10.js/00.ethers/20.v6/01.features.md @@ -55,7 +55,7 @@ const tx = { }; ``` -### CustomData Fields +### CustomData fields - `gasPerPubdata`: Specifies L2 gas per published byte. - `factoryDeps`: Array of contract bytecodes for deployment. diff --git a/content/sdk/10.js/00.ethers/20.v6/03.providers.md b/content/sdk/10.js/00.ethers/20.v6/03.providers.md index 0aaf96b4..83fefb23 100644 --- a/content/sdk/10.js/00.ethers/20.v6/03.providers.md +++ b/content/sdk/10.js/00.ethers/20.v6/03.providers.md @@ -1,43 +1,47 @@ --- title: Providers -description: A guide to Web3 Provider objects for ZKsync integration +description: Web3 Provider objects for ZKsync integration tags: ["zksync", "ethereum", "zksync Era", "transactions", "provider"] --- A Web3 Provider object provides application-layer access to underlying blockchain networks. -The [`zksync-ethers`](https://www.npmjs.com/package/zksync-ethers) library supports provider methods from -the [`ethers.js`](https://docs.ethers.io/v6/api/providers) library and supplies additional functionality. +The [`zksync-ethers`](https://www.npmjs.com/package/zksync-ethers/v/5.0.0) library supports +provider methods from the [`ethers.js`](https://docs.ethers.io/v6/api/providers) library and +supplies additional functionality. -## Available providers +Two providers are available: -- **Provider**: Extends [`ethers.JsonRpcProvider`](https://docs.ethers.org/v6/api/providers/jsonrpc/#about-jsonrpcProvider) -with ZKsync specific methods. -- **BrowserProvider**: Extends the ZKsync Era `Provider` class for better compatibility with Web3 wallets. +- [`Provider`](/sdk/js/ethers/v6/providers#provider): Supplies the same functionality as + [`ethers.providers.JsonRpcProvider`](https://docs.ethers.org/v6/api/providers/jsonrpc-provider/#JsonRpcProvider) + and extends it with ZKsync-specific methods. +- [`Web3Provider`](/sdk/js/ethers/v6/providers#web3provider): Extends the ZKsync +Era [`Provider`](/sdk/js/ethers/v6/providers#provider) class to +make it more compatible + with Web3 wallets. ::callout{icon="i-heroicons-light-bulb"} -Use `BrowserProvider` for browser integrations. +Use the [`Web3Provider`](/sdk/js/ethers/v6/providers#web3provider) for browser integrations. :: ## `Provider` ### `constructor` -Creates a zksync Era `Provider` object. +Returns a ZKsync Era `Provider` object. -**Parameters:** +#### Inputs -| Parameter | Type | Description | -| ---------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------- | -| `url?` | [`ethers.FetchRequest`](https://docs.ethers.org/v6/api/utils/fetching/#FetchRequest) | Network RPC URL (optional). | -| `network?` | [`ethers.Networkish`](https://docs.ethers.org/v6/api/providers/#Networkish) | Network name, chain ID, or object with network details. | -| `options?` | `any` | Additional provider options (optional). | +| Parameter | Type | Description | +| ---------- | -------------------------------------------------------------------------------------- | -------------------------- | +| `url?` | string or [`ConnectionInfo`](https://docs.ethers.org/v6/api/utils/web/#ConnectionInfo) | Network RPC URL | +| `network?` | `ethers.providers.Networkish` | Network name | ```ts -constructor(url ? : ethers.FetchRequest | string, network ? : Networkish, options ? : any) +constructor(url?: ConnectionInfo | string, network?: ethers.providers.Networkish) ``` -**Example:** +#### Example ```ts import { Provider } from "zksync-ethers"; @@ -45,60 +49,21 @@ import { Provider } from "zksync-ethers"; const provider = new Provider("https://sepolia.era.zksync.dev"); ``` -The constructor for the `Provider` class creates an instance of the provider object, which connects your application to -the zksync Era network. The `url` parameter specifies the network RPC URL, the `network` -parameter allows you to define the network details, and `options` provides additional customization. - -### `broadcastTransaction` - -Overrides the Ethers implementation. - -**Parameters:** - -| Parameter | Type | Description | -| ---------- | -------- | --------------------- | -| `signedTx` | `string` | Signed transaction. | - -```ts -async broadcastTransaction(signedTx: string): Promise -``` - -**Example:** - -```ts -import { Provider, types, Wallet } from "zksync-ethers"; - -const PRIVATE_KEY = ""; -const provider = Provider.getDefaultProvider(types.Network.Sepolia); -const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); - -const signedTx = await wallet.signTransaction({ - to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618", - value: ethers.parseEther("0.01"), -}); -const tx = await provider.broadcastTransaction(signedTx); -console.log(tx.hash); -``` - -The `broadcastTransaction` method sends a signed transaction to the network. This is useful when you want to broadcast -a transaction that has already been signed by a wallet. The method returns a transaction response, which includes the -transaction hash. - ### `estimateFee` -Returns an estimated [`Fee`](/sdk/js/ethers/v6/types#fee) for the requested transaction. +Returns an estimated [`Fee`](/sdk/js/ethers/v6/types#fee) for requested transaction. -**Parameters:** +#### Inputs -| Parameter | Type | Description | -| ------------- | ------------------------------------------------------------------------------------ | ---------------------- | -| `transaction` | [`TransactionRequest`](https://docs.ethers.org/v6/api/providers/#TransactionRequest) | Transaction request. | +| Parameter | Type | Description | +| ------------- | ---------------------------------------------------------------------------------------------------- | -------------------- | +| `transaction` | [`TransactionRequest`](https://docs.ethers.org/v6/api/providers/types/#providers-TransactionRequest) | Transaction request. | ```ts async estimateFee(transaction: TransactionRequest): Promise ``` -**Example:** +Helper function: [toJSON](#tojson). ```ts import { Provider, types } from "zksync-ethers"; @@ -107,30 +72,24 @@ const provider = Provider.getDefaultProvider(types.Network.Sepolia); const fee = await provider.estimateFee({ from: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618", - value: `0x${BigInt(7_000_000_000).toString(16)}`, + value: `0x${BigNumber.from(7_000_000_000).toString(16)}`, }); console.log(`Fee: ${toJSON(fee)}`); ``` -The `estimateFee` method estimates the fee required for a transaction. This is important for users to know how much they -need to pay in transaction fees before sending the transaction. The method returns a `Fee` object that -contains the estimated fee details. - ### `estimateGas` -Returns an estimate of the gas required to submit a transaction. +Returns an estimate of the amount of gas required to submit a transaction to the network. -**Parameters:** - -| Parameter | Type | Description | -| --------- | ------------------------------------------------------------------------------------ | ---------------------- | -| `_tx` | [`TransactionRequest`](https://docs.ethers.org/v6/api/providers/#TransactionRequest) | Transaction request. | +| Parameter | Type | Description | +| ------------- | -------------------- | -------------------- | +| `transaction` | `TransactionRequest` | Transaction request. | ```ts -async estimateGas(_tx: TransactionRequest): Promise +async estimateGas(transaction: utils.Deferrable): Promise ``` -**Example:** +#### Example ```ts import { Provider, types, utils } from "zksync-ethers"; @@ -144,24 +103,52 @@ const gasTokenApprove = await provider.estimateGas({ console.log(`Gas for token approval tx: ${gasTokenApprove}`); ``` -The `estimateGas` method estimates the amount of gas required for a transaction. This is essential for determining the -cost of a transaction in terms of gas, ensuring you have enough funds to cover the transaction cost. +```ts +import { Provider, types, utils } from "zksync-ethers"; +import { ethers, BigNumber } from "ethers"; + +const ADDRESS = "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049"; +const RECEIVER = "0xa61464658AfeAf65CccaaFD3a512b69A83B77618"; +const provider = Provider.getDefaultProvider(types.Network.Sepolia); +const tokenAddress = "0x927488F48ffbc32112F1fF721759649A89721F8F"; // Crown token which can be minted for free +const paymasterAddress = "0x13D0D8550769f59aa241a41897D4859c87f7Dd46"; // Paymaster for Crown token + +const paymasterParams = utils.getPaymasterParams(paymasterAddress, { + type: "ApprovalBased", + token: tokenAddress, + minimalAllowance: BigNumber.from(1), + innerInput: new Uint8Array(), +}); + +const tokenApprove = await provider.estimateGas({ + from: ADDRESS, + to: tokenAddress, + data: utils.IERC20.encodeFunctionData("approve", [RECEIVER, 1]), + customData: { + gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, + paymasterParams, + }, +}); +console.log(`Gas for token approval using EIP-712 tx: ${tokenApprove}`); +``` ### `estimateGasL1` -Returns an estimate of the gas required to submit a transaction from L1 to L2. +Returns an estimate of the amount of gas required to submit a transaction from L1 to L2 as a `BigNumber` object. + +Calls the [`zks_estimateL1ToL2`](https://docs.zksync.io/build/api-reference/zks-rpc#zks_estimategasl1tol2) JSON-RPC method. -**Parameters:** +#### Inputs -| Parameter | Type | Description | -| ------------- | -------------------------------------------------------- | ---------------------- | -| `transaction` | [`TransactionRequest`](/sdk/js/ethers/v6/types#transactionrequest) | Transaction request. | +| Parameter | Type | Description | +| ------------- | ----------------------------------------------------- | -------------------- | +| `transaction` | [`TransactionRequest`](/sdk/js/ethers/v6/types#transactionrequest) | Transaction request. | ```ts -async estimateGasL1(transaction: TransactionRequest): Promise +async estimateGasL1(transaction: TransactionRequest): Promise ``` -**Example:** +#### Example ```ts import { Provider, types } from "zksync-ethers"; @@ -175,39 +162,39 @@ const gasL1 = await provider.estimateGasL1({ gasPerPubdata: 800, }, }); -console.log(`L1 gas: ${BigInt(gasL1)}`); +console.log(`L1 gas: ${BigNumber.from(gasL1)}`); ``` -The `estimateGasL1` method estimates the gas required for a transaction from Layer 1 (L1) to Layer 2 (L2). This is -crucial for cross-layer operations, ensuring you know the gas cost for moving transactions between layers. - ### `estimateGasTransfer` Returns the gas estimation for a transfer transaction. -**Parameters:** +Calls internal method [`getTransferTx`](https://github.com/zksync-sdk/zksync-ethers/blob/ethers-v6/src/utils.ts) +to get the transfer transaction and sends it to the [`estimateGas`](#estimategas) method. + +#### Inputs -| Parameter | Type | Description | -| ------------------ | ------------------------------------------------------------------------ | --------------------------------- | -| `token` | `Address` | Token address. | -| `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Ethers overrides object (optional).| +| Parameter | Type | Description | +| ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `token` | `Address` | Token address. | +| `amount` | `BigNumberish` | Amount of token. | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasTransfer(transaction: { - to: Address; - amount: BigNumberish; - from ? : Address; - token ? : Address; - paymasterParams ?: PaymasterParams; - overrides ? : ethers.Overrides; -}): Promise + to: Address; + amount: BigNumberish; + from?: Address; + token?: Address; + paymasterParams ?: PaymasterParams; + overrides?: ethers.CallOverrides; +}): Promise ``` -**Example:** +#### Example ```ts import { Provider, types, utils } from "zksync-ethers"; @@ -222,38 +209,38 @@ const gasTransfer = await provider.estimateGasTransfer({ console.log(`Gas for transfer tx: ${gasTransfer}`); ``` -The `estimateGasTransfer` method estimates the gas required for a token transfer transaction. This helps users determine -the cost of transferring tokens between addresses. - ### `estimateGasWithdraw` Returns the gas estimation for a withdrawal transaction. -**Parameters:** +Calls internal method [`getWithdrawTx`](#getwithdrawtx) to get the +withdrawal transaction and sends it to the [`estimateGas`](#estimategas) method. + +#### Inputs -| Parameter | Type | Description | -| ------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | -| `token` | `Address` | Token address. | -| `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `bridgeAddress?` | `Address` | Bridge address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| Parameter | Type | Description | +| ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `token` | `Address` | Token address. | +| `amount` | `BigNumberish` | Amount of token. | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `bridgeAddress?` | `Address` | Bridge address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasWithdraw(transaction: { - token: Address; - amount: BigNumberish; - from ? : Address; - to ? : Address; - bridgeAddress ? : Address; - paymasterParams ?: PaymasterParams; - overrides ? : ethers.Overrides; -}): Promise + token: Address; + amount: BigNumberish; + from?: Address; + to?: Address; + bridgeAddress?: Address; + paymasterParams ?: PaymasterParams; + overrides?: ethers.CallOverrides; +}): Promise ``` -**Example:** +#### Example ```ts import { Provider, types, utils } from "zksync-ethers"; @@ -261,7 +248,7 @@ import { Provider, types, utils } from "zksync-ethers"; const provider = Provider.getDefaultProvider(types.Network.Sepolia); const gasWithdraw = await provider.estimateGasWithdraw({ token: utils.ETH_ADDRESS, - amount: 7_000_000_000, + amount: 7_000_000, to: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", from: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", }); @@ -274,26 +261,26 @@ Returns gas estimation for an L1 to L2 execute operation. #### Inputs -| Parameter | Type | Description | -| -------------------- | ------------------ | ----------------------------------------------------------------------------------------------------- | -| `contractAddress` | `Address` | Address of contract. | -| `calldata` | `string` | The transaction call data. | -| `caller?` | `Address` | Caller address (optional). | -| `l2Value?` | `BigNumberish` | Current L2 gas value (optional). | -| `factoryDeps?` | `BytesLike[]` | Byte array containing contract bytecode. | -| `gasPerPubdataByte?` | `BigNumberish` | Constant representing current amount of gas per byte (optional). | -| `overrides?` | `ethers.Overrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| Parameter | Type | Description | +| -------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------- | +| `contractAddress` | `Address` | Address of contract. | +| `calldata` | `BytesLike` | The transaction call data. | +| `caller?` | `Address` | Caller address. | +| `l2Value?` | `BigNumberish` | Current L2 gas value. | +| `factoryDeps?` | `BytesLike[]` | Byte array containing contract bytecode. | +| `gasPerPubdataByte?` | `BigNumberish` | Constant representing current amount of gas per byte. | +| `overrides?` | `ethers.PayableOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateL1ToL2Execute(transaction: { - contractAddress: Address; - calldata: string; - caller ? : Address; - l2Value ? : BigNumberish; - factoryDeps ? : ethers.BytesLike[]; - gasPerPubdataByte ? : BigNumberish; - overrides ? : ethers.Overrides; -}): Promise + contractAddress: Address; + calldata: BytesLike; + caller?: Address; + l2Value?: BigNumberish; + factoryDeps?: ethers.BytesLike[]; + gasPerPubdataByte?: BigNumberish; + overrides?: ethers.PayableOverrides; +}): Promise ``` #### Example @@ -308,7 +295,7 @@ const gasL1ToL2 = await provider.estimateL1ToL2Execute({ caller: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", l2Value: 7_000_000_000, }); -console.log(`Gas L1 to L2: ${BigInt(gasL1ToL2)}`); +console.log(`Gas L1 to L2: ${BigNumber.from(gasL1ToL2)}`); ``` ### `getAllAccountBalances` @@ -330,7 +317,7 @@ async getAllAccountBalances(address: Address): Promise #### Example -Helper function: [toJSON](#tojson). +Helper function: [toJSON](/sdk/js/ethers/v6/providers#tojson). ```ts import { Provider, types } from "zksync-ethers"; @@ -342,7 +329,7 @@ console.log(`All balances: ${toJSON(balances)}`); ### `getBalance` -Returns the user's balance as a `bigint` object for an (optional) block tag and (optional) token. +Returns the user's balance as a `BigNumber` object for an (optional) block tag and (optional) token. When block and token are not supplied, `committed` and `ETH` are the default values. @@ -351,8 +338,8 @@ When block and token are not supplied, `committed` and `ETH` are the default val | Parameter | Type | Description | | --------------- | ---------- | ------------------------------------------------------------------------------------- | | `address` | `Address` | Account address. | -| `blockTag?` | `BlockTag` | Block tag for getting the balance on. Latest `committed` block is default (optional). | -| `tokenAddress?` | `Address` | Token address. ETH is default (optional). | +| `blockTag?` | `BlockTag` | Block tag for getting the balance on. Latest `committed` block is default. | +| `tokenAddress?` | `Address` | Token address. ETH is default. | ```ts async getBalance(address: Address, blockTag?: BlockTag, tokenAddress?: Address) @@ -393,15 +380,8 @@ console.log(`Base token: ${await provider.getBaseTokenContractAddress()}`); Returns block from the network, or false if there is no block. -#### Inputs - -| Parameter | Type | Description | -| --------------------- | ---------- | ----------------------------------------------------------- | -| `blockHashOrBlockTag` | `BlockTag` | Block tag for getting the balance on. | -| `includeTxs?` | `boolean` | Whether to fetch transactions that are in block (optional). | - ```ts -async getBlock(blockHashOrBlockTag: BlockTag, includeTxs?: boolean): Promise +async getBlock(blockHashOrBlockTag: BlockTag | string | Promise): Promise ``` #### Example @@ -484,7 +464,7 @@ import { Provider, types } from "zksync-ethers"; // Bytecode hash can be computed by following these steps: // const testnetPaymasterBytecode = await provider.getCode(await provider.getTestnetPaymasterAddress()); -// const testnetPaymasterBytecodeHash = ethers.hexlify(utils.hashBytecode(testnetPaymasterBytecode)); +// const testnetPaymasterBytecodeHash = ethers.utils.hexlify(utils.hashBytecode(testnetPaymasterBytecode)); const testnetPaymasterBytecodeHash = "0x010000f16d2b10ddeb1c32f2c9d222eb1aea0f638ec94a81d4e916c627720e30"; @@ -576,8 +556,8 @@ console.log(`Default bridges: ${toJSON(await provider.getDefaultBridgeAddresses( ### `connectL2Bridge` -Returns contract wrapper. If given address is shared bridge address it returns -Il2SharedBridge and if its legacy it returns Il2Bridge. +Returns contract wrapper. If given address is shared bridge address it +returns Il2SharedBridge and if its legacy it returns Il2Bridge. #### Inputs @@ -671,16 +651,17 @@ console.log(`Fee: ${utils.toJSON(feeParams)}`); ### `getFilterChanges` -Returns an array of logs by calling Ethereum method [`eth_getFilterChanges`](https://ethereum.github.io/execution-apis/api-documentation/). +Returns an array of logs by calling Ethereum method +[`eth_getFilterChanges`.](https://ethereum.github.io/execution-apis/api-documentation/) #### Inputs -| Parameter | Type | Description | -| --------- | -------- | ------------- | -| `idx` | `bigint` | Filter index. | +| Parameter | Type | Description | +| --------- | ----------- | ------------- | +| `idx` | `BigNumber` | Filter index. | ```ts -async getFilterChanges(idx: bigint): Promise> +async getFilterChanges(idx: BigNumber): Promise> ``` #### Example @@ -696,12 +677,28 @@ const filter = await provider.newFilter({ const result = await provider.getFilterChanges(filter); ``` +### `getFormatter` + +Static utility method that returns a `Formatter` object for processing readable block data. + +```ts +static override getFormatter(): Formatter +``` + +#### Example + +```ts +import { Provider, types } from "zksync-ethers"; + +const formatter = Provider.getFormatter(); +``` + ### `getGasPrice` Returns an estimate (best guess) of the gas price to use in a transaction. ```ts -async getGasPrice(): Promise +async getGasPrice(): Promise ``` #### Example @@ -773,7 +770,7 @@ console.log(`L1 batch details: ${toJSON(await provider.getL1BatchDetails(l1Batch ### `getL1BatchNumber` Returns the latest L1 batch number. - + Calls the [`zks_getL1BatchNumber`](https://docs.zksync.io/build/api-reference/zks-rpc#zks_l1batchnumber) JSON-RPC method. ```ts @@ -795,9 +792,9 @@ Returns a L2 transaction from L1 transaction response. #### Inputs -| Parameter | Type | Description | -| -------------- | -------------------------------------------------------------------------------------- | ------------------------ | -| `l1TxResponse` | [`TransactionResponse`](https://docs.ethers.org/v6/api/providers/#TransactionResponse) | L1 transaction response. | +| Parameter | Type | Description | +| -------------- | ------------------------------------------------------------------------------------------------------ | ------------------------ | +| `l1TxResponse` | [`TransactionResponse`](https://docs.ethers.org/v6/api/providers/types/#providers-TransactionResponse) | L1 transaction response. | ```ts async getL2TransactionFromPriorityOp(l1TxResponse: ethers.TransactionResponse): Promise @@ -830,7 +827,7 @@ Calls the [`zks_getL2ToL1LogProof`](https://docs.zksync.io/build/api-reference/z | Parameter | Type | Description | | --------- | ----------- | ---------------------------------------------------------------- | | `txHash` | `BytesLike` | Hash of the L2 transaction the L2 to L1 log was produced within. | -| `index?` | `number` | The index of the L2 to L1 log in the transaction (optional). | +| `index?` | `number` | The index of the L2 to L1 log in the transaction. | ```ts async getLogProof(txHash: BytesLike, index ? : number): Promise @@ -852,16 +849,17 @@ console.log(`Log ${toJSON(await provider.getLogProof(tx, 0))}`); ### `getLogs` -Returns an array of all logs that match a filter with a given id by calling Ethereum method [`eth_getLogs.`](https://ethereum.github.io/execution-apis/api-documentation/) +Returns an array of all logs that match a filter with a given id by calling Ethereum method +[`eth_getLogs.`](https://ethereum.github.io/execution-apis/api-documentation/) #### Inputs -| Parameter | Type | Description | -| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -| `filter` | [`Filter`](https://docs.ethers.org/v6/api/providers/#Filter) or [`FilterByBlockHash`](https://docs.ethers.org/v6/api/providers/#FilterByBlockHash) | Filter query. | +| Parameter | Type | Description | +| --------- | --------------------------------------------------------------------------- | ------------- | +| `filter` | [`Filter`] or [`FilterByBlockHash`] or `Promise` | Filter query. | ```ts -async getLogs(filter: Filter | FilterByBlockHash): Promise +getLogs(filter: Filter | FilterByBlockHash | Promise): Promise> ``` #### Example @@ -869,7 +867,7 @@ async getLogs(filter: Filter | FilterByBlockHash): Promise Helper function: [toJSON](#tojson). ```ts -import { Provider, types, utils } from "zksync-ethers"; +import { Provider, types } from "zksync-ethers"; const provider = Provider.getDefaultProvider(types.Network.Sepolia); console.log(`Logs: ${toJSON(await provider.getLogs({ fromBlock: 0, toBlock: 5, address: utils.L2_ETH_TOKEN_ADDRESS }))}`); @@ -903,7 +901,7 @@ Returns the transaction confirmation data that is part of `L2->L1` message. | Name | Type | Description | |----------| ----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `txHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0. | ```ts async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ @@ -930,14 +928,14 @@ console.log(`Confirmation data: ${utils.toJSON(await provider.getPriorityOpConfi ### `getPriorityOpResponse` -Returns a [`TransactionResponse`](https://docs.ethers.org/v6/api/providers/#TransactionResponse) +Returns a [`TransactionResponse`](https://docs.ethers.org/v6/api/providers/types/#providers-TransactionResponse) as a `PriorityOpResponse` object. #### Inputs -| Parameter | Type | Description | -| -------------- | -------------------------------------------------------------------------------------- | ------------------------ | -| `l1TxResponse` | [`TransactionResponse`](https://docs.ethers.org/v6/api/providers/#TransactionResponse) | L1 transaction response. | +| Parameter | Type | Description | +| -------------- | ------------------------------------------------------------------------------------------------------ | ------------------------ | +| `l1TxResponse` | [`TransactionResponse`](https://docs.ethers.org/v6/api/providers/types/#providers-TransactionResponse) | L1 transaction response. | ```ts async getPriorityOpResponse(l1TxResponse: ethers.TransactionResponse): Promise @@ -961,8 +959,8 @@ if (l1TxResponse) { ### `getProof` -Returns Merkle [`proofs`](/sdk/js/ethers/v6/types#storageproof) for one or more storage values at the -specified account along with a Merkle proof of their authenticity. +Returns Merkle [`proofs`](/sdk/js/ethers/v6/types#storageproof) for one or more storage values at the specified account along +with a Merkle proof of their authenticity. Calls the [`zks_getProof`](https://docs.zksync.io/build/api-reference/zks-rpc#zks_getproof) JSON-RPC method. @@ -993,16 +991,16 @@ const address = "0x082b1BB53fE43810f646dDd71AA2AB201b4C6b04"; // Ensure the address is a 256-bit number by padding it // because rawNonces slot uses uint256 for mapping addresses and their nonces. -const addressPadded = ethers.zeroPadValue(address, 32); +const addressPadded = ethers.utils.hexZeroPad(wallet.address, 32); // Convert the slot number to a hex string and pad it to 32 bytes. -const slotPadded = ethers.zeroPadValue(ethers.toBeHex(0), 32); +const slotPadded = ethers.utils.hexZeroPad(ethers.utils.hexlify(0), 32); // Concatenate the padded address and slot number. const concatenated = addressPadded + slotPadded.slice(2); // slice to remove '0x' from the slotPadded // Hash the concatenated string using Keccak-256. -const storageKey = ethers.keccak256(concatenated); +const storageKey = ethers.utils.keccak256(concatenated); const l1BatchNumber = await provider.getL1BatchNumber(); const storageProof = await provider.getProof(utils.NONCE_HOLDER_ADDRESS, [storageKey], l1BatchNumber); @@ -1083,7 +1081,7 @@ console.log(`Testnet paymaster: ${await provider.getTestnetPaymasterAddress()}`) ### `getTransaction` Returns a specified L2 transaction response object by overriding the -[Ethers implementation](https://docs.ethers.org/v5/api/providers/provider/#Provider-getTransaction). +[Ethers implementation](https://docs.ethers.org/v6/api/providers/provider/#Provider-getTransaction). #### Inputs @@ -1091,8 +1089,8 @@ Returns a specified L2 transaction response object by overriding the | --------- | -------- | ----------------- | | `txHash` | `string` | Transaction hash. | -```ts -async getTransaction(txHash: string): Promise +```typescript +async getTransaction(hash: string | Promise): Promise ``` #### Example @@ -1115,7 +1113,7 @@ await txHandle.waitFinalize(); Returns data from a specific transaction given by the transaction hash. -Calls the [`zks_getTransactionDetails`](https://docs.zksync.io/build/api-reference/zks-rpc#zks_gettransactiondetails) +Calls the [`getTransactionDetails`](https://docs.zksync.io/build/api-reference/zks-rpc#zks_gettransactiondetails) JSON-RPC method. #### Inputs @@ -1145,7 +1143,7 @@ console.log(`Transaction details: ${toJSON(await provider.getTransactionDetails( Returns the transaction receipt from a given hash number. -[Ethers implementation.](https://docs.ethers.org/v5/api/providers/provider/#Provider-getTransactionReceipt) +[Ethers implementation.](https://docs.ethers.org/v6/api/providers/provider/#Provider-getTransactionReceipt) #### Inputs @@ -1154,7 +1152,7 @@ Returns the transaction receipt from a given hash number. | `txHash` | `string` | Transaction hash. | ```ts -async getTransactionReceipt(txHash: string): Promise +async getTransactionReceipt(transactionHash: string | Promise): Promise ``` #### Example @@ -1202,14 +1200,14 @@ Returns the populated transfer transaction. #### Inputs -| Parameter | Type | Description | -| ------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | -| `token` | `Address` | Token address. | -| `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| Parameter | Type | Description | +| ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `token` | `Address` | Token address. | +| `amount` | `BigNumberish` | Amount of token. | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getTransferTx(transaction: { @@ -1218,7 +1216,7 @@ async getTransferTx(transaction: { from ? : Address; token ? : Address; paymasterParams?: PaymasterParams; - overrides ? : ethers.Overrides; + overrides?: ethers.CallOverrides; }): Promise ``` @@ -1270,15 +1268,15 @@ Returns the populated withdrawal transaction. #### Inputs -| Parameter | Type | Description | -| ------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | -| `token` | `Address` | Token address. | -| `amount` | `BigNumberish` | Amount of token. | -| `from?` | `Address` | From address (optional). | -| `to?` | `Address` | To address (optional). | -| `bridgeAddress?` | `Address` | Bridge address (optional). | -| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| Parameter | Type | Description | +| ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `token` | `Address` | Token address. | +| `amount` | `BigNumberish` | Amount of token. | +| `from?` | `Address` | From address. | +| `to?` | `Address` | To address. | +| `bridgeAddress?` | `Address` | Bridge address. | +| `paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | `ethers.CallOverrides` | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getWithdrawTx(transaction: { @@ -1288,7 +1286,7 @@ async getWithdrawTx(transaction: { to ? : Address; bridgeAddress ? : Address; paymasterParams?: PaymasterParams; - overrides ? : ethers.Overrides; + overrides?: ethers.CallOverrides; }): Promise ``` @@ -1395,7 +1393,8 @@ console.log(`L1 chain ID: ${await provider.l1ChainId()}`); ### `l1TokenAddress` -Returns the L1 token address equivalent for a L2 token address as they are not equal. ETH's address is set to zero address. +Returns the L1 token address equivalent for a L2 token address as they are not equal. +ETH's address is set to zero address. ::callout{icon="i-heroicons-exclamation-triangle" color="amber"} Only works for tokens bridged on default ZKsync Era bridges. @@ -1422,7 +1421,8 @@ console.log(`L1 token address: ${await provider.l1TokenAddress("0x3e7676937A7E96 ### `l2TokenAddress` -Returns the L2 token address equivalent for a L1 token address as they are not equal. ETH's address is set to zero address. +Returns the L2 token address equivalent for a L1 token address as they are not equal. +ETH's address is set to zero address. ::callout{icon="i-heroicons-exclamation-triangle" color="amber"} Only works for tokens bridged on default ZKsync Era bridges. @@ -1450,10 +1450,11 @@ console.log(`L2 token address: ${await provider.l2TokenAddress("0x5C221E77624690 ### `newBlockFilter` -Returns a new block filter by calling Ethereum method [`eth_newBlockFilter.`](https://ethereum.github.io/execution-apis/api-documentation/) +Returns a new block filter by calling Ethereum method +[`eth_newBlockFilter.`](https://ethereum.github.io/execution-apis/api-documentation/) ```ts -async newBlockFilter(): Promise +async newBlockFilter(): Promise ``` #### Example @@ -1473,12 +1474,12 @@ and passing a filter object. #### Inputs -| Parameter | Type | Description | -| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -| `filter` | [`FilterByBlockHash`](https://docs.ethers.org/v6/api/providers/#FilterByBlockHash) or [`Filter`](https://docs.ethers.org/v6/api/providers/#Filter) | Filter query. | +| Parameter | Type | Description | +| --------- | --------------------------------------------------------------- | ------------- | +| `filter` | [`EventFilter`](/sdk/js/ethers/v6/types#eventfilter) or `Promise` | Filter query. | ```ts -async newFilter(filter: FilterByBlockHash | Filter): Promise +async newFilter(filter: EventFilter | Promise): Promise ``` #### Example @@ -1503,7 +1504,7 @@ Returns a new pending transaction filter by calling Ethereum method and passing a filter object. ```ts -async newPendingTransactionsFilter(): Promise +async newPendingTransactionsFilter(): Promise ``` #### Example @@ -1555,14 +1556,46 @@ const wallet = new Wallet(PRIVATE_KEY, provider); const txWithOutputs = await provider.sendRawTransactionWithDetailedOutput( await wallet.signTransaction({ to: Wallet.createRandom().address, - value: ethers.parseEther("0.01"), + value: ethers.utils.parseEther("0.01"), }) ); console.log(`Transaction with detailed output: ${utils.toJSON(txWithOutputs)}`); ``` -## `BrowserProvider` +### `sendTransaction` + +Override of [Ethers implementation.](https://docs.ethers.org/v6/api/providers/provider/#Provider-sendTransaction) + +#### Inputs + +| Parameter | Type | Description | +| ------------- | ----------------------------- | ------------------- | +| `transaction` | `string` or `Promise` | Signed transaction. | + +```ts +async sendTransaction(transaction: string | Promise): Promise +``` + +#### Example + +```ts +import { Provider, types, Wallet, utils } from "zksync-ethers"; + +const PRIVATE_KEY = ""; +const provider = Provider.getDefaultProvider(types.Network.Sepolia); +const wallet = new Wallet(PRIVATE_KEY, provider); + +const signedTx = await wallet.signTransaction({ + to: "0xa61464658AfeAf65CccaaFD3a512b69A83B77618", + value: ethers.utils.parseEther("0.01"), +}); + +const tx = await provider.sendTransaction(signedTx); +console.log(tx.hash); +``` + +## `Web3Provider` Use this provider for Web3 browser wallet integrations for easy compatibility with Metamask, WalletConnect, and other popular browser wallets. @@ -1570,25 +1603,25 @@ WalletConnect, and other popular browser wallets. ### `constructor` Returns a provider object by extending the constructor of the `Provider` class and accepting -an `Eip1193Provider` instead of a node URL. +an `ExternalProvider` instead of a node URL. #### Inputs -| Parameter | Type | Description | -| ---------- | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | -| `ethereum` | [`Eip1193Provider`](https://docs.ethers.org/v6/api/providers/#Eip1193Provider) | The `Eip1193Provider` class instance. For instance, Metamask is `window.ethereum`. | -| `network?` | [`Networkish`](https://docs.ethers.org/v6/api/providers/#Networkish) | Network name (optional). | +| Parameter | Type | Description | +| ---------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `provider` | [`ExternalProvider`](https://docs.ethers.org/v6/api/providers/other/#Web3Provider--ExternalProvider)) | The `ethers.providers.ExternalProvider` class instance. For instance, Metamask is `window.ethereum`. | +| `network?` | `Networkish` | The description of the network. | -```ts -constructor(ethereum: Eip1193Provider, network?: Networkish) +```typescript +constructor(provider: ExternalProvider, network?: ethers.providers.Networkish) ``` #### Example ```ts -import { BrowserProvider } from "zksync-ethers"; +import { Web3Provider } from "zksync-ethers"; -const provider = new BrowserProvider(window.ethereum); +const provider = new Web3Provider(window.ethereum); ``` ### `estimateGas` @@ -1597,20 +1630,20 @@ Returns gas estimate by overriding the ZKsync Era [`estimateGas`](#estimategas) #### Inputs -| Parameter | Type | Description | -| ------------- | ----------------------------------------------------- | -------------------- | -| `transaction` | [`TransactionRequest`](/sdk/js/ethers/v6/types#transactionrequest) | Transaction request. | +| Parameter | Type | Description | +| ------------- | -------------------- | -------------------- | +| `transaction` | `TransactionRequest` | Transaction request. | ```ts -async estimateGas(transaction: TransactionRequest): Promise +async estimateGas(transaction: ethers.utils.Deferrable) ``` #### Example ```ts -import { BrowserProvider } from "zksync-ethers"; +import { Web3Provider } from "zksync-ethers"; -const provider = new BrowserProvider(window.ethereum); +const provider = new Web3Provider(window.ethereum); const gas = await provider.estimateGas({ to: "", amount: ethers.parseEther("0.01"), @@ -1620,37 +1653,38 @@ console.log(`Gas: ${gas}`); ### `getSigner` -Override of [Ethers implementation](https://docs.ethers.org/v6/api/providers/jsonrpc/#JsonRpcApiProvider-getSigner). +Override of [Ethers implementation](https://docs.ethers.org/v6/api/providers/jsonrpc-provider/#JsonRpcProvider-getSigner). #### Inputs -| Parameter | Type | Description | -| ---------- | -------------------- | ------------------------------------ | -| `address?` | `number` or `string` | Account address or index (optional). | +| Parameter | Type | Description | +| ----------------- | -------------------- | ------------------------------------ | +| `addressOrIndex?` | `number` or `string` | Account address or index. | ```ts -async getSigner(address ? : number | string): Promise +getSigner(addressOrIndex?: number | string): Signer ``` #### Example ```ts -import { BrowserProvider } from "zksync-ethers"; +import { Web3Provider } from "zksync-ethers"; -const provider = new BrowserProvider(window.ethereum); -const signer = await provider.getSigner(); +const provider = new Web3Provider(window.ethereum); +const signer = provider.getSigner(); ``` ### `send` -Returns a provider request object by overriding the [Ethers implementation](https://docs.ethers.org/v6/api/providers/jsonrpc/#JsonRpcApiProvider-send). +Returns a provider request object by overriding the +[Ethers implementation](https://docs.ethers.org/v6/api/providers/jsonrpc-provider/#JsonRpcProvider-send). #### Inputs | Parameter | Type | Description | | --------- | ------------ | ---------------------------------- | | `method` | `Address` | Request method name as string. | -| `params?` | `Array` | Parameters of any type (optional). | +| `params?` | `Array` | Parameters of any type. | ```ts async send(method: string, params?: Array): Promise diff --git a/content/sdk/10.js/00.ethers/20.v6/04.accounts.md b/content/sdk/10.js/00.ethers/20.v6/04.accounts.md index b758a52c..777465b6 100644 --- a/content/sdk/10.js/00.ethers/20.v6/04.accounts.md +++ b/content/sdk/10.js/00.ethers/20.v6/04.accounts.md @@ -1,6 +1,7 @@ --- title: Accounts -description: +description: Manage accounts and sign transactions in zksync-ethers. +tag: ["zksync", "account management", "wallet creation", "transaction signing", "cryptocurrency", "ethereum"] --- ## Overview @@ -25,8 +26,8 @@ description: | Parameter | Type | Description | | ------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | | `privateKey` | `string` or [`ethers.SigningKey`](https://docs.ethers.org/v6/api/crypto/#SigningKey) | The private key of the Ethereum account. | -| `providerL2?` | [`Provider`](/sdk/js/ethers/v6/providers#provider) | A ZKsync node provider. Needed for interaction with ZKsync (optional). | -| `providerL1?` | [`ethers.Provider`](https://docs.ethers.org/v6/api/providers/#Provider) | An Ethereum node provider. Needed for interaction with L1 (optional). | +| `providerL2?` | [`Provider`](/sdk/js/ethers/v6/providers#provider) | A ZKsync node provider. Needed for interaction with ZKsync. | +| `providerL1?` | [`ethers.Provider`](https://docs.ethers.org/v6/api/providers/#Provider) | An Ethereum node provider. Needed for interaction with L1. | ```ts constructor(privateKey: string | ethers.SigningKey, providerL2?: Provider, providerL1?: ethers.Provider) @@ -45,6 +46,10 @@ const ethProvider = ethers.getDefaultProvider("sepolia"); const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); ``` +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + ### `fromMnemonic` Creates a `Wallet` with the `provider` as L1 provider and a private key that is built from the `mnemonic` passphrase. @@ -54,7 +59,7 @@ Creates a `Wallet` with the `provider` as L1 provider and a private key that is | Parameter | Type | Description | | ----------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------- | | `mnemonic` | `string` | The mnemonic of the private key. | -| `provider?` | [`ethers.Provider`](https://docs.ethers.org/v6/api/providers/#Provider) | An Ethereum node provider. Needed for interaction with L1 (optional). | +| `provider?` | [`ethers.Provider`](https://docs.ethers.org/v6/api/providers/#Provider) | An Ethereum node provider. Needed for interaction with L1. | ```ts static fromMnemonic(mnemonic: string, provider?: ethers.Provider): Wallet @@ -82,7 +87,7 @@ Creates a `Wallet` from encrypted `json` file using provided `password`. | ----------- | ------------------------ | -------------------------------------------------------------------------------------------------------------- | | `json` | `string` | Encrypted json file. | | `password` | `string` or `Uint8Array` | Password for encrypted json file. | -| `callback?` | `ProgressCallback` | If callback is provided, it is called periodically during decryption so that any UI can be updated (optional). | +| `callback?` | `ProgressCallback` | If callback is provided, it is called periodically during decryption so that any UI can be updated. | ```ts static async fromEncryptedJson(json: string, password: string | Uint8Array, callback? : ProgressCallback): Promise @@ -318,7 +323,7 @@ Returns the amount of the token the `Wallet` has. | Parameter | Type | Description | | ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------- | -| `token?` | `Address` | The address of the token. ETH by default (optional). | +| `token?` | `Address` | The address of the token. ETH by default. | | `blockTag` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts @@ -350,8 +355,8 @@ Returns the amount of the token the `Wallet` has on Ethereum. | Parameter | Type | Description | | ----------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | -| `token?` | `Address` | The address of the token. ETH by default (optional). | -| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `token?` | `Address` | The address of the token. ETH by default. | +| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getBalanceL1(token?: Address, blockTag?: BlockTag): Promise @@ -405,7 +410,7 @@ Returns account's nonce number. | Parameter | Type | Description | | ----------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | -| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `blockTag?` | `BlockTag` | In which block a balance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getNonce(blockTag?: BlockTag): Promise @@ -624,9 +629,9 @@ token within the same interface. | ------------------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | | `transaction.to` | `Address` | The address of the recipient. | | `transaction.amount` | `BigNumberish` | The amount of the token to transfer. | -| `transaction.token?` | `Address` | The address of the token. `ETH` by default (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.token?` | `Address` | The address of the token. `ETH` by default. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async transfer(transaction: { @@ -755,8 +760,8 @@ Returns the amount of approved tokens for a specific L1 bridge. | Parameter | Type | Description | | ---------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | -| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge` (optional). | -| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge`. | +| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getAllowanceL1( @@ -792,7 +797,7 @@ Bridging ERC20 tokens from Ethereum requires approving the tokens to the ZKsync | ------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | | `amount` | `BigNumberish` | The amount of the token to be approved. | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async approveERC20( @@ -829,8 +834,8 @@ Returns base cost for L2 transaction. | Name | Type | Description | | --------------------------- | -------------- | ------------------------------------------------------------------------------------------------- | | `params.gasLimit` | `BigNumberish` | The `gasLimit` for the L2 contract call. | -| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call (optional). | +| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call. | ```ts async getBaseCost(params: { @@ -1039,7 +1044,8 @@ specified L1 bridge (default one or the one defined in `transaction.bridgeAddres In this case, depending on is the chain ETH-based or not `transaction.approveERC20` or `transaction.approveBaseERC20` can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge, token approval will be skipped. -To check the amount of approved tokens for a specific bridge, use the [`allowanceL1`](#getallowancel1) method. +To check the amount of approved tokens for a specific bridge, +use the [`allowanceL1`](/sdk/js/ethers/v6/accounts#getallowancel1) method. #### Inputs @@ -1047,18 +1053,18 @@ To check the amount of approved tokens for a specific bridge, use the [`allowanc |-------------------------------------| ------------------------------------------------------------------------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveBaseOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveBaseOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | ```ts async deposit(transaction: { @@ -1208,14 +1214,14 @@ Returns populated deposit transaction. | -------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getDepositTx(transaction: { @@ -1262,14 +1268,14 @@ Gas of approving ERC20 token is not included in estimation. | -------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasDeposit(transaction: @@ -1315,11 +1321,11 @@ Retrieves the full needed ETH fee for the deposit. Returns the L1 fee and the L2 | Parameter | Type | Description | | -------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getFullRequiredDepositFee(transaction: { @@ -1395,10 +1401,10 @@ network to the target account on L1 network. | ------------------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to withdraw. | -| `transaction.to?` | `Address` | The address of the recipient on L1 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address of the recipient on L1. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async withdraw(transaction: { @@ -1504,8 +1510,8 @@ Proves the inclusion of the L2 -> L1 withdrawal message. | Name | Type | Description | | ---------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | +| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async finalizeWithdrawal(withdrawalHash: BytesLike, index: number = 0, overrides?: ethers.Overrides): Promise @@ -1536,7 +1542,7 @@ Returns whether the withdrawal transaction is finalized on the L1 network. | Name | Type | Description | | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | ```ts async isWithdrawalFinalized(withdrawalHash: BytesLike, index: number = 0): Promise @@ -1568,7 +1574,7 @@ from the withdrawal transaction's log on the L1 network. | Name | Type | Description | | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0. | ```ts async finalizeWithdrawalParams(withdrawalHash: BytesLike, index: number = 0): Promise @@ -1601,13 +1607,13 @@ Existing allowance for the bridge is not checked; allowance is calculated solely |----------------------------------| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteAllowanceParams(transaction: { @@ -1660,14 +1666,14 @@ Request execution of L2 transaction from L1. | -------------------------------- |--------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async requestExecute(transaction: { @@ -1715,14 +1721,14 @@ Returns populated request execute transaction. | -------------------------------- | ------------------------------------------------------------------------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteTx(transaction: { @@ -1769,14 +1775,14 @@ Estimates the amount of gas required for a request execute transaction. | -------------------------------- | ------------------------------------------------------------------------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts estimateGasRequestExecute(transaction: { @@ -1823,7 +1829,7 @@ Returns the transaction confirmation data that is part of `L2->L1` message. | Name | Type | Description | |----------| ----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `txHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0. | ```ts async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ @@ -2078,8 +2084,8 @@ But for convenience, the `Wallet` class has `transfer` method, which can transfe | `transaction.to` | `Address` | The address of the recipient. | | `transaction.amount` | `BigNumberish` | The amount of the token to transfer. | | `transaction.token?` | `Address` | The address of the token. `ETH` by default. | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`,
`gasPrice`, `value`, etc (optional). | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`,
`gasPrice`, `value`, etc. | ```ts async transfer(transaction: { @@ -2218,10 +2224,10 @@ to the target account on L1 network. | ------------------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to withdraw. | -| `transaction.to?` | `Address` | The address of the recipient on L1 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address of the recipient on L1. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async withdraw(transaction: { @@ -2499,8 +2505,8 @@ Returns the amount of approved tokens for a specific L1 bridge. | Parameter | Type | Description | | ---------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | -| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge` (optional). | -| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option (optional). | +| `bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge, either `L1EthBridge` or `L1Erc20Bridge`. | +| `blockTag?` | `BlockTag` | In which block an allowance should be checked on. `committed`, i.e. the latest processed one is the default option. | ```ts async getAllowanceL1( @@ -2533,7 +2539,7 @@ Bridging ERC20 tokens from Ethereum requires approving the tokens to the ZKsync | ------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | | `token` | `Address` | The Ethereum address of the token. | | `amount` | `BigNumberish` | The amount of the token to be approved. | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async approveERC20( @@ -2565,7 +2571,7 @@ Returns base cost for L2 transaction. | Name | Type | Description | | --------------------------- | -------------- | ------------------------------------------------------------------------------------------------ | | `params.gasLimit` | `BigNumberish` | The `gasLimit` for the L2 contract call. | -| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | +| `params.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | | `params.gasPrice?` | `BigNumberish` | The L1 gas price of the L1 transaction that will send the request for an execute call (optional. | ```ts @@ -2770,7 +2776,8 @@ specified L1 bridge (default one or the one defined in `transaction.bridgeAddres In this case, depending on is the chain ETH-based or not `transaction.approveERC20` or `transaction.approveBaseERC20` can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge, token approval will be skipped. -To check the amount of approved tokens for a specific bridge, use the [`allowanceL1`](#getallowancel1) method. +To check the amount of approved tokens for a specific bridge, +use the [`allowanceL1`](/sdk/js/ethers/v6/accounts#getallowancel1) method. #### Inputs @@ -2778,18 +2785,18 @@ To check the amount of approved tokens for a specific bridge, use the [`allowanc |-------------------------------------| ------------------------------------------------------------------------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.approveBaseOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.approveERC20?` | `boolean` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.approveBaseERC20?` | `boolean` | Whether or not should the base token approval be performed under the hood. Set this flag to `true` if you bridge a base token and didn't call the `approveERC20` function beforehand. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.approveBaseOverrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | ```ts async deposit(transaction: { @@ -2919,14 +2926,14 @@ Returns populated deposit transaction. | -------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getDepositTx(transaction: { @@ -2970,14 +2977,14 @@ Gas of approving ERC20 token is not included in estimation. | -------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to deposit. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides,
this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive l2Value. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasDeposit(transaction: @@ -3020,11 +3027,11 @@ Retrieves the full needed ETH fee for the deposit. Returns the L1 fee and the L2 | Parameter | Type | Description | | -------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token to deposit. `ETH` by default. | -| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`) (optional). | -| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address that will receive the deposited tokens on L2. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. Defaults to the default ZKsync bridge (either `L1EthBridge` or `L1Erc20Bridge`). | +| `transaction.customBridgeData?` | `BytesLike` | Additional data that can be sent to a bridge. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | Whether or not should the token approval be performed under the hood. Set this flag to `true` if you bridge an ERC20 token and didn't call the `approveERC20` function beforehand. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getFullRequiredDepositFee(transaction: { @@ -3092,8 +3099,8 @@ Proves the inclusion of the L2 -> L1 withdrawal message. | Name | Type | Description | | ---------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0) (optional). | -| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0). | +| `overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async finalizeWithdrawal(withdrawalHash: BytesLike, index: number = 0, overrides?: ethers.Overrides): Promise @@ -3121,7 +3128,7 @@ Returns whether the withdrawal transaction is finalized on the L1 network. | Name | Type | Description | | ---------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0) (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0). | ```ts async isWithdrawalFinalized(withdrawalHash: BytesLike, index: number = 0): Promise @@ -3150,7 +3157,7 @@ from the withdrawal transaction's log on the L1 network. | Name | Type | Description | | ---------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | `withdrawalHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0) (optional). | +| `index?` | `number` | In case there were multiple withdrawals in one transaction, you may pass an index of the withdrawal you want to finalize. Defaults to 0). | ```ts async finalizeWithdrawalParams(withdrawalHash: BytesLike, index: number = 0): Promise @@ -3180,13 +3187,13 @@ Existing allowance for the bridge is not checked; allowance is calculated solely |----------------------------------| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteAllowanceParams(transaction: { @@ -3239,14 +3246,14 @@ Request execution of L2 transaction from L1. | -------------------------------- |--------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `transaction.contractAddress` | `Address` | The L2 contract to be called. | | `transaction.calldata` | `BytesLike` | The input of the L2 transaction. | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async requestExecute(transaction: { @@ -3290,16 +3297,16 @@ Returns populated deposit transaction. | Name | Type | Description | | -------------------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `transaction.contractAddress` | `Address` | The L2 contract to be called (optional). | -| `transaction.calldata` | `BytesLike` | The input of the L2 transaction (optional). | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.contractAddress?` | `Address` | The L2 contract to be called. | +| `transaction.calldata?` | `BytesLike` | The input of the L2 transaction. | +| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async getRequestExecuteTx(transaction: { @@ -3343,16 +3350,16 @@ Estimates the amount of gas required for a request execute transaction. | Name | Type | Description | | -------------------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `transaction.contractAddress` | `Address` | The L2 contract to be called (optional). | -| `transaction.calldata` | `BytesLike` | The input of the L2 transaction (optional). | -| `transaction.l2GasLimit` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2 (optional). | -| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2. (optional). | -| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction (optional). | -| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2 (optional). | -| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction (optional). | -| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte (optional). | -| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value` (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.contractAddress?` | `Address` | The L2 contract to be called. | +| `transaction.calldata?` | `BytesLike` | The input of the L2 transaction. | +| `transaction.l2GasLimit?` | `BigNumberish` | Maximum amount of L2 gas that transaction can consume during execution on L2. | +| `transaction.mintValue?` | `BigNumberish` | The amount of base token that needs to be minted on non-ETH-based L2.. | +| `transaction.l2Value?` | `BigNumberish` | `msg.value` of L2 transaction. | +| `transaction.factoryDeps?` | `ethers.BytesLike[]` | An array of L2 bytecodes that will be marked as known on L2. | +| `transaction.operatorTip?` | `BigNumberish` | (_currently is not used_) If the ETH value passed with the transaction is not explicitly stated in the overrides, this field will be equal to the tip the operator will receive on top of the base cost of the transaction. | +| `transaction.gasPerPubdataByte?` | `BigNumberish` | The L2 gas price for each published L1 calldata byte. | +| `transaction.refundRecipient?` | `Address` | The address on L2 that will receive the refund for the transaction. If the transaction fails, it will also be the address to receive `l2Value`. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass L1 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async estimateGasRequestExecute(transaction: { @@ -3398,7 +3405,7 @@ Returns the transaction confirmation data that is part of `L2->L1` message. | Name | Type | Description | |----------| ----------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `txHash` | `BytesLike` | Hash of the L2 transaction where the withdrawal was initiated. | -| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0 (optional). | +| `index?` | `number` | In case there were multiple transactions in one message, you may pass an index of the transaction which confirmation data should be fetched. Defaults to 0. | ```ts async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ @@ -3411,7 +3418,7 @@ async getPriorityOpConfirmation(txHash: string, index: number = 0): Promise<{ #### Example -Helper function: [toJSON](providers#tojson). +Helper function: [toJSON](/sdk/js/ethers/v6/providers). ```ts import { Provider, L1Signer, types } from "zksync-ethers"; @@ -3449,7 +3456,7 @@ By default, uses [`signPayloadWithECDSA`](/sdk/js/ethers/v6/smart-account-utils# | Parameter | Type | Description | | ----------- | ----------------------------------------------------- | ----------------------------------------------------------------------- | | `signer` | [`SmartAccountSigner`](/sdk/js/ethers/v6/types#smartaccountsigner) | Contains necessary properties for signing payloads. | -| `provider?` | [`Provider`](/sdk/js/ethers/v6/providers#provider) or `null` | The provider to connect to. Can be `null` for offline usage (optional). | +| `provider?` | [`Provider`](/sdk/js/ethers/v6/providers#provider) or `null` | The provider to connect to. Can be `null` for offline usage. | ```ts constructor(signer: SmartAccountSigner, provider?: null | Provider) @@ -3527,7 +3534,7 @@ Returns the balance of the account. | Parameter | Type | Description | | ---------- | ---------- | -------------------------------------------------------------------------------- | -| `token?` | `Address` | The token address to query balance for. Defaults to the native token (optional). | +| `token?` | `Address` | The token address to query balance for. Defaults to the native token. | | `blockTag` | `BlockTag` | The block tag to get the balance at. Defaults to `committed`. | ```ts @@ -3778,10 +3785,10 @@ network to the target account on L1 network. | ------------------------------ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | | `transaction.token` | `Address` | The address of the token. `ETH` by default. | | `transaction.amount` | `BigNumberish` | The amount of the token to withdraw. | -| `transaction.to?` | `Address` | The address of the recipient on L1 (optional). | -| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used (optional). | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc (optional). | +| `transaction.to?` | `Address` | The address of the recipient on L1. | +| `transaction.bridgeAddress?` | `Address` | The address of the bridge contract to be used. | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`, `gasPrice`, `value`, etc. | ```ts async withdraw(transaction: { @@ -3856,8 +3863,8 @@ Transfer ETH or any ERC20 token within the same interface. | `transaction.to` | `Address` | The address of the recipient. | | `transaction.amount` | `BigNumberish` | The amount of the token to transfer. | | `transaction.token?` | `Address` | The address of the token. `ETH` by default. | -| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters (optional). | -| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`,
`gasPrice`, `value`, etc (optional). | +| `transaction.paymasterParams?` | [`PaymasterParams`](/sdk/js/ethers/v6/types#paymasterparams) | Paymaster parameters. | +| `transaction.overrides?` | [`ethers.Overrides`](https://docs.ethers.org/v6/api/contract/#Overrides) | Transaction's overrides which may be used to pass l2 `gasLimit`,
`gasPrice`, `value`, etc. | ```ts async transfer(transaction: { diff --git a/content/sdk/10.js/00.ethers/20.v6/05.accounts-l1-l2.md b/content/sdk/10.js/00.ethers/20.v6/05.accounts-l1-l2.md index 82d4b05d..ab49b45c 100644 --- a/content/sdk/10.js/00.ethers/20.v6/05.accounts-l1-l2.md +++ b/content/sdk/10.js/00.ethers/20.v6/05.accounts-l1-l2.md @@ -1,48 +1,46 @@ --- -title: Accounts | L1<->L2 Transactions -description: +title: Account Management | L1-L2 Transactions +description: Methods for handling transactions between L1 and L2 networks with ZKsync. +tags: ["zksync", "l1 to l2 transactions", "cryptocurrency", "ethereum", "wallet"] --- -This section explores the methods which allow the -[account](/sdk/js/ethers/v6/accounts) to send transactions among both L1 to L2 networks. +Learn the methods for managing accounts and facilitating transactions between Layer 1 (L1) and Layer 2 (L2) +networks using ZKsync. -If you want some background on how L1<->L2 interaction works on ZKsync, go through the -[introduction](https://docs.zksync.io/build/developer-reference/l1-l2-interop.html). +For an overview of L1-L2 interactions on ZKsync, visit the [Developer Reference](https://docs.zksync.io/build/developer-reference/l1-l2-interop.html). -Full examples of actions below are available on the [getting started](/sdk/js/ethers/v6/getting-started) page. +The examples of the following actions can be found on the [getting started](/sdk/js/ethers/v6/getting-started) page. ## Deposit -`Wallet` and `L1Signer` objects provide a deposit workflow. -For more information, please refer to the method specification [`Deposit`](/sdk/js/ethers/v6/accounts#deposit). +The `Wallet` and `L1Signer` classes offer a seamless deposit workflow. Detailed information can be found in +the [`Deposit`](/sdk/js/ethers/v6/accounts#deposit-1) method specification. -For a complete example of how to execute the deposit workflow, take a look at the following: -[Deposit ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/01_deposit.ts). +For a guide on executing deposits, refer to this example: [Deposit ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/01_deposit.ts). -## Request execute +## Request execution -`Wallet` and `L1Signer` objects provide an option to request execution of L2 transaction from L1. For more information, -please refer to the method specification [`requestExecute`](/sdk/js/ethers/v6/accounts#requestexecute). +Using `Wallet` and `L1Signer`, you can request the execution of L2 transactions from L1. More details are available +in the [`requestExecute`](/sdk/js/ethers/v6/accounts#requestexecute) method specification. -## Base cost +## Calculate base cost -`Wallet` and `L1Signer` objects provide an option to calculate base cost for L2 transaction. For more information, -please refer to the method specification [`getBaseCost`](/sdk/js/ethers/v6/accounts#getbasecost). +The `Wallet` and `L1Signer` classes also provide a way to calculate the base cost for L2 transactions. Refer to +the [`getBaseCost`](/sdk/js/ethers/v6/accounts#getbasecost) method specification for further details. ## Claim failed deposit -`Wallet` and `L1Signer` objects provide a claim fail deposit workflow. For more information, -please refer to the method specification [`claimFailedDeposit`](/sdk/js/ethers/v6/accounts#claimfaileddeposit). +In the event of a failed deposit, `Wallet` and `L1Signer` offer a recovery workflow. More information can be +found in the [`claimFailedDeposit`](/sdk/js/ethers/v6/accounts#claimfaileddeposit) method specification. -## Finalize withdraw +## Finalize withdrawal -`Wallet` and `L1Signer` objects provide a finalize withdraw workflow. For more information, -please refer to the method specification [`finalizeWithdrawal`](/sdk/js/ethers/v6/accounts#finalizewithdrawal). +`Wallet` and `L1Signer` support the workflow for finalizing withdrawals. Detailed instructions are available +in the [`finalizeWithdrawal`](/sdk/js/ethers/v6/accounts#finalizewithdrawal) method specification. -## Withdrawal +## Withdraw -`Wallet` and `Signer` objects provide a withdrawal workflow. For more information, -please refer to the method specification [`Withdraw`](/sdk/js/ethers/v6/accounts#withdraw). +Both `Wallet` and `Signer` classes support withdrawal workflows. For more details, see +the [`Withdraw`](/sdk/js/ethers/v6/accounts#withdraw) method specification. -For a complete example of how to execute the deposit workflow, take a look at the following: -[Withdraw ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/04_withdraw.ts). +For a complete walkthrough on executing withdrawals, check out this example: [Withdraw ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/04_withdraw.ts). diff --git a/content/sdk/10.js/00.ethers/20.v6/06.contracts.md b/content/sdk/10.js/00.ethers/20.v6/06.contracts.md index 13ef8c33..14958f9f 100644 --- a/content/sdk/10.js/00.ethers/20.v6/06.contracts.md +++ b/content/sdk/10.js/00.ethers/20.v6/06.contracts.md @@ -1,13 +1,25 @@ --- -title: Contracts -description: +title: Contract +description: Managing and deploying smart contracts with ZKsync. +tags: ["zksync", "smart contracts", "ethereum", "contractfactory", "erc20 tokens"] --- -`zksync-ethers` does not implement any new `Contract` class, since `ethers.Contract` fully works out of the box. -However, for convenience, the library still re-exports this class. +The `zksync-ethers` library leverages the existing `ethers.Contract` class for smart contract management, ensuring +full compatibility out of the box. For convenience, this class is re-exported within the library. -Since deploying smart contracts on ZKsync has some differences from deploying on Ethereum, -there is a need for a specific `ContractFactory` method. It supports the same interface as `ethers.ContractFactory`. +## Deploying smart contracts -In order to pay for smart contract interactions in ERC20 tokens, `customData` override should be used. -You can read more about accessing ZKsync features in [the features chapter](/sdk/js/ethers/v6/features). +Deploying smart contracts on ZKsync differs slightly from Ethereum. To accommodate these differences, a +specific `ContractFactory` method is provided. This method supports the same interface as `ethers.ContractFactory`. + +### ContractFactory + +The `ContractFactory` method facilitates the deployment of smart contracts on the ZKsync network. This method is +essential due to the unique requirements of deploying contracts on ZKsync compared to Ethereum. + +### Paying with ERC20 tokens + +To pay for smart contract interactions using ERC20 tokens, the `customData` override should be utilized. This +feature allows for more flexible payment options within the ZKsync network. + +For more details on accessing ZKsync-specific features, refer to the [ZKsync Era Features](/sdk/js/ethers/v6/features). diff --git a/content/sdk/10.js/00.ethers/20.v6/07.utils.md b/content/sdk/10.js/00.ethers/20.v6/07.utils.md index 93c78fd6..442fff52 100644 --- a/content/sdk/10.js/00.ethers/20.v6/07.utils.md +++ b/content/sdk/10.js/00.ethers/20.v6/07.utils.md @@ -1,6 +1,7 @@ --- title: Utilities -description: +description: Essential utilities for building on ZKsync Era. +tags: ["zksync", "utilities", "ethereum", "smart contracts"] --- The [utilities library](https://github.com/zksync-sdk/zksync-ethers/blob/main/src/utils.ts) contains @@ -269,7 +270,9 @@ const l2ContractAddress = utils.applyL1ToL2Alias(l1ContractAddress); // l2ContractAddress = "0x813A42B8205E5DedCd3374e5f4419843ADa77FFC" ``` -See also [`undol1tol2alias`](#undol1tol2alias). +::callout +See also [`undol1tol2alias`](/sdk/js/ethers/v6/utils#undol1tol2alias). +:: ### `checkBaseCost` @@ -362,7 +365,7 @@ Returns the hash of an EIP712 transaction. | Parameter | Type | Description | | --------------- | ---------------------------------------------------------------------- | ---------------------------------------------- | | `transaction` | `Transaction` or [`TransactionRequest`](/sdk/js/ethers/v6/types#transactionrequest) | EIP-712 transaction. | -| `ethSignature?` | [`EthereumSignature`](/sdk/js/ethers/v6/types#ethereumsignature) | ECDSA signature of the transaction (optional). | +| `ethSignature?` | [`EthereumSignature`](/sdk/js/ethers/v6/types#ethereumsignature) | ECDSA signature of the transaction. | ```ts function eip712TxHash(transaction: any, ethSignature?: EthereumSignature): string; @@ -385,8 +388,8 @@ Check out the default bridges documentation. | `token` | `Address` | Token address. | | `amount` | `BigNumberish` | Deposit amount. | | `to` | `Address` | Recipient address. | -| `from?` | `Address` | Sender address (optional). | -| `gasPerPubdataByte?` | `BigNumberish` | Current gas per byte of pubdata (optional). | +| `from?` | `Address` | Sender address. | +| `gasPerPubdataByte?` | `BigNumberish` | Current gas per byte of pubdata. | ```ts async function estimateDefaultBridgeDepositL2Gas( @@ -561,8 +564,14 @@ const isValidSignature = await utils.isECDSASignatureCorrect(ADDRESS, message, s // isValidSignature = true ``` +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + +::callout See also [`isMessageSignatureCorrect()`](#ismessagesignaturecorrect) and [`isTypedDataSignatureCorrect()`](#istypeddatasignaturecorrect) to validate signatures. +:: ### `isEIP1271SignatureCorrect` @@ -582,8 +591,10 @@ the function returns true if the validation process results in the `EIP1271_MAGI async function isEIP1271SignatureCorrect(provider: Provider, address: string, msgHash: string, signature: SignatureLike): Promise; ``` +::callout See also [`isMessageSignatureCorrect()`](#ismessagesignaturecorrect) and [`isTypedDataSignatureCorrect()`](#istypeddatasignaturecorrect) to validate signatures. +:: ### `isETH` @@ -774,7 +785,7 @@ Serializes an EIP712 transaction and include a signature if it is provided. Thro | Parameter | Type | Description | | ------------- | ----------------- | ---------------------------------------------------------------------- | | `transaction` | `TransactionLike` | Transaction that needs to be serialized. | -| `signature?` | `SignatureLike` | Ethers signature that needs to be included in transactions (optional). | +| `signature?` | `SignatureLike` | Ethers signature that needs to be included in transactions. | ```ts function serializeEip712(transaction: TransactionLike, signature?: ethers.SignatureLike): string; @@ -843,4 +854,6 @@ const l1ContractAddress = utils.undoL1ToL2Alias(l2ContractAddress); // const l1ContractAddress = "0x702942B8205E5dEdCD3374E5f4419843adA76Eeb" ``` +::callout See also [`applyl1tol2alias`](#applyl1tol2alias). +:: diff --git a/content/sdk/10.js/00.ethers/20.v6/08.paymaster-utils.md b/content/sdk/10.js/00.ethers/20.v6/08.paymaster-utils.md index 6947de00..22a1b152 100644 --- a/content/sdk/10.js/00.ethers/20.v6/08.paymaster-utils.md +++ b/content/sdk/10.js/00.ethers/20.v6/08.paymaster-utils.md @@ -1,15 +1,15 @@ --- title: Paymaster Utilities -description: +description: Essential utilities for using paymasters on ZKsync Era. +tags: ["zksync", "paymaster", "blockchain", "ethereum", "cryptocurrency"] --- -The [paymaster utilities library](https://github.com/zksync-sdk/zksync-ethers/blob/main/src/paymaster-utils.ts) contains -essential utilities for using paymasters on ZKsync Era. +The [paymaster utilities library](https://github.com/zksync-sdk/zksync-ethers/blob/main/src/paymaster-utils.ts) +provides key utilities for interacting with paymasters on the ZKsync Era. ## Contract interfaces -Constant ABI definition for -the [Paymaster Flow Interface](https://github.com/matter-labs/era-contracts/blob/583cb674a2b942dda34e9f46edb5a9f5b696b90a/l2-contracts/contracts/interfaces/IPaymasterFlow.sol). +Define the constant ABI for the [Paymaster Flow Interface](https://github.com/matter-labs/era-contracts/blob/583cb674a2b942dda34e9f46edb5a9f5b696b90a/l2-contracts/contracts/interfaces/IPaymasterFlow.sol): ```ts const PAYMASTER_FLOW_ABI = new ethers.Interface(IPaymasterFlowABI); @@ -19,7 +19,7 @@ const PAYMASTER_FLOW_ABI = new ethers.Interface(IPaymasterFlowABI); ### `getApprovalBasedPaymasterInput` -Returns encoded input for an approval-based paymaster. +Returns the encoded input for an approval-based paymaster. #### Inputs @@ -33,7 +33,7 @@ function getApprovalBasedPaymasterInput(paymasterInput: ApprovalBasedPaymasterIn ### `getGeneralPaymasterInput` -As above but for general-based paymaster. +Returns the encoded input for a general-based paymaster. #### Inputs @@ -47,8 +47,7 @@ function getGeneralPaymasterInput(paymasterInput: GeneralPaymasterInput): BytesL ### `getPaymasterParams` -Returns a correctly-formed `paymasterParams` object for common -[paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction/paymasters#built-in-paymaster-flows). +Returns a correctly-formed `paymasterParams` object for common [paymaster flows](https://docs.zksync.io/build/developer-reference/account-abstraction/paymasters#built-in-paymaster-flows). #### Inputs @@ -65,7 +64,7 @@ Find out more about the [`PaymasterInput` type](/sdk/js/ethers/v6/types). #### Examples -Creating `General` paymaster parameters. +Creating `General` paymaster parameters: ```ts const paymasterAddress = "0x0a67078A35745947A37A552174aFe724D8180c25"; @@ -75,7 +74,7 @@ const paymasterParams = utils.getPaymasterParams(paymasterAddress, { }); ``` -Creating `ApprovalBased` paymaster parameters. +Creating `ApprovalBased` paymaster parameters: ```ts const result = utils.getPaymasterParams("0x0a67078A35745947A37A552174aFe724D8180c25", { diff --git a/content/sdk/10.js/00.ethers/20.v6/09.smart-account-utils.md b/content/sdk/10.js/00.ethers/20.v6/09.smart-account-utils.md index abb1bce2..c2d30348 100644 --- a/content/sdk/10.js/00.ethers/20.v6/09.smart-account-utils.md +++ b/content/sdk/10.js/00.ethers/20.v6/09.smart-account-utils.md @@ -1,6 +1,7 @@ --- title: Smart Account Utilities -description: +description: Utilities for signing payloads and populating transactions with ECDSA and multiple ECDSA keys. +tags: ["zksync", "smart accounts", "ecdsa", "blockchain", "cryptocurrency"] --- ## Functions @@ -40,6 +41,10 @@ const txHash = EIP712Signer.getSignedDigest(tx); const result = await utils.signPayloadWithECDSA(txHash, PRIVATE_KEY); ``` +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: + Sign message hash. ```ts diff --git a/content/sdk/10.js/00.ethers/20.v6/10.types.md b/content/sdk/10.js/00.ethers/20.v6/10.types.md index 280424d9..191bd256 100644 --- a/content/sdk/10.js/00.ethers/20.v6/10.types.md +++ b/content/sdk/10.js/00.ethers/20.v6/10.types.md @@ -1,23 +1,30 @@ --- title: Types and Interfaces -description: +description: Definitions and interfaces used in ZKsync Era. +tags: ["zksync", "types", "interfaces", "ethereum", "blockchain"] --- ## `AccountAbstractionVersion` Enumerated list of account abstraction versions. +::collapsible + - None = `0` - Used for contracts that are not accounts. - Version1 = `1` - Used for contracts that are accounts. +:: ## `AccountNonceOrdering` Enumerated list of account nonce ordering formats. +::collapsible + - Sequential = `0` - Nonces should be ordered in the same way as in externally owned accounts (EOAs). This means, for instance, that the operator will always wait for a transaction with nonce `X` before processing a transaction with nonce `X+1`. - Arbitrary = `1` - Nonces can be ordered in arbitrary order. +:: ## `Address` @@ -27,10 +34,13 @@ Enumerated list of account nonce ordering formats. Interface representation of approval based paymaster input. +::collapsible + - `type`: `'ApprovalBased'` - The type of the paymaster input. - `token`: `Address` - The address of the token to be approved. - `minimalAllowance`: `bigint` - The minimum allowance required for the token approval. - `innerInput`: `BytesLike`- The additional input data.; +:: ## `BalancesMap` @@ -42,6 +52,8 @@ Type defining a map object containing accounts and their balances. Interface representation of batch details. +::collapsible + - `number`: `number` - L1 batch number. - `timestamp`: `number`- Unix timestamp when the batch was processed. - `l1TxCount`: `number` - Number of L1 transactions included in the batch. @@ -57,6 +69,7 @@ Interface representation of batch details. - `l1GasPrice`: `number` - L1 gas price at the time of the block's execution. - `l2FairGasPrice`: `number` - Fair gas price on L2 at the time of the block's execution. - `baseSystemContractsHashes`: `object` - Hashes of the base system contracts involved in the batch. +:: ## `Block` @@ -71,6 +84,8 @@ definition with additional fields. Interface representation of block details. +::collapsible + - `number`: `number` - Number of the block. - `timestamp`: `number` - Unix timestamp when the block was committed. - `l1BatchNumber`: `number` - Corresponding L1 batch number. @@ -89,11 +104,14 @@ Interface representation of block details. - `baseSystemContractsHashes`: `object` - A collection of hashes for the base system contracts involved in the block. - `operatorAddress`: `string` - Address of the operator who committed the block. - `protocolVersion`: `string` - version of the ZKsync protocol the block was committed under. +:: ## `BlockTag` Pipe-delimited list of block labels that includes block number in binary and hex plus block statuses. +::collapsible + - `BigNumberish` - `string` // block hash - `committed` @@ -101,6 +119,7 @@ Pipe-delimited list of block labels that includes block number in binary and hex - `latest` - `earliest` - `pending` +:: ## `ContractAccountInfo` @@ -114,48 +133,65 @@ version and nonce ordering format. Interface representation of deployment information. +::collapsible + - `sender`: `Address` - The account responsible for deployment. - `bytecodeHash`: `string` - The hash of the contract/account bytecode. - `deployedAddress`: `Address` - The deployed address of the contract/address. +:: ## `DeploymentType` Pipe-delimited choice of two deployment types that support all `create2` variants. +::collapsible + - `create` - `createAccount` +:: ## `Eip712Meta` Contains EIP712 transaction metadata. +::collapsible + - `gasPerPubdata?`: `BigNumberish` - The maximum amount of gas the user is willing to pay for a single byte of pubdata. - `factoryDeps?`: `BytesLike[]` - An array of bytes containing the bytecode of the contract being deployed and any related contracts it can deploy. - `customSignature?`: `BytesLike` - Custom signature used for cases where the signer's account is not an EOA. - `paymasterParams?`: `PaymasterParams` - Parameters for configuring the custom paymaster for the transaction. +:: ## `EthereumSignature` Interface representation of an Ethereum signature. +::collapsible + - `v`: `number` - The recovery id. - `r`: `BytesLike` - The "r" value of the signature. - `s`: `BytesLike` - The "s" value of the signature. +:: ## `Fee` Interface representation of transaction fee parameters. +::collapsible + - `gasLimit`: `bigint` - The maximum amount of gas that can be used. - `gasPerPubdataLimit`: `bigint` - The gas limit per unit of public data. - `maxPriorityFeePerGas`: `bigint` - The maximum priority fee per unit of gas to incentivize miners. - `maxFeePerGas`: `bigint` - The maximum fee per unit of gas that the sender is willing to pay. +:: ## `FeeParams` Interface representation of fee parameter configuration. +::collapsible + - `V2`: - Fee parameter configuration for the current version of the ZKsync protocol. - `config`: - Settings related to transaction fee computation. - `minimal_l2_gas_price`: `bigint` - Minimal gas price on L2. @@ -166,40 +202,52 @@ Interface representation of fee parameter configuration. - `max_pubdata_per_batch`: `bigint` - Maximum amount of public data allowed per batch. - `l1_gas_price`: `bigint` - Current L1 gas price. - `l1_pubdata_price`: `bigint` - Price of storing public data on L1. + :: ## `FinalizeWithdrawalParams` Interface representation of finalize withdrawal parameters. +::collapsible + - `l1BatchNumber`: `number | null` - The L2 batch number where the withdrawal was processed. - `l2MessageIndex`: `number` - The position in the L2 logs Merkle tree of the l2Log that was sent with the message. - `l2TxNumberInBlock`: `number | null` - The L2 transaction number in the batch, in which the log was sent. - `message`: `any` - The L2 withdraw data, stored in an L2 -> L1 message. - `sender`: `string` - The L2 address which sent the log. - `proof`: `string[]` - The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization. +:: ## `FullDepositFee` Interface representation of full deposit fee containing fees for both L1 and L2 transactions. +::collapsible + - `maxFeePerGas?`: `bigint` - The maximum fee per gas for L1 transaction. - `maxPriorityFeePerGas?`: `bigint` - The maximum priority fee per gas for L1 transaction. - `gasPrice?`: `bigint` - The gas price for L2 transaction. - `baseCost`: `bigint` - The base cost of the deposit transaction on L2. - `l1GasLimit`: `bigint` - The gas limit for L1 transaction. - `l2GasLimit`: `bigint` - The gas limit for L2 transaction. +:: ## `GeneralPaymasterInput` Interface representation of general paymaster input. +::collapsible + - `type`: `'General'` - The type of the paymaster input. - `innerInput`: `BytesLike` - The additional input data. +:; ## `L2ToL1Log` Interface representation of a layer 2 to layer 1 transaction log. +::collapsible + - `blockNumber`: `number` - The block number. - `blockHash`: `string` - The block hash. - `l1BatchNumber`: `number` - The batch number on L1. @@ -214,6 +262,7 @@ Interface representation of a layer 2 to layer 1 transaction log. - `value`: `string` - The 32 bytes of information that was sent in the log. - `transactionHash`: `string` - The transaction hash. - `logIndex`: `number` - The log index. +:: ## `Log` @@ -221,59 +270,80 @@ Interface representation of log that extends Ethers [`providers.Log`](https://docs.ethers.org/v5/api/providers/types/#providers-Log) and supplies the layer 1 batch number. +::collapsible + - `l1BatchNumber`: `number` - The batch number on L1. +:: ## `LogProof` Interface representation of message proof. +::collapsible + - `id`: `number` - Identifier of the log within the transaction. - `proof`: `string[]` - Each element represents a piece of the proof for the specified log. - `root`: `string` - Root hash of the proof, anchoring it to a specific state in the blockchain. +:: ## `MessageProof` -::callout{icon="i-heroicons-exclamation-triangle" color="amber"} -Deprecated in favor of `[LogProof](#logproof)` -:: - Interface representation of message proof. +::collapsible + - `id`: `number` - Identifier of the log within the transaction. - `proof`: `string[]` - Each element represents a piece of the proof for the specified log. - `root`: `string` - Root hash of the proof, anchoring it to a specific state in the blockchain. +:: + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +Deprecated in favor of `[LogProof](#logproof)` +:: ## `Network` Enumerated list of networks and their ids. +::collapsible + - Mainnet = `1` - Ropsten = `3` - Rinkeby = `4` - Sepolia = `6`, - localhost = `9`, - EraTestNode = `10`, +:: ## `PaymasterInput` Type definition for a paymaster input specified as either approval based or general. +::collapsible + - `ApprovalBasedPaymasterInput` | `GeneralPaymasterInput` +:: ## `PaymasterParams` Type defining a paymaster by address and the bytestream input. +::collapsible + - `paymaster`: `Address` - The address of the paymaster. - `paymasterInput`: `BytesLike` - The bytestream input for the paymaster. +:: ## `PayloadSigner` Signs various types of payloads, optionally using a some kind of secret. +::collapsible + - `payload`: `BytesLike` - The payload that needs to be sign. - `secret`: `any` - The secret used for signing the `payload`. - `provider` `null | Provider` - The provider is used to fetch data from the network if it is required for signing. +:: ## `PriorityOpResponse` @@ -282,38 +352,52 @@ Interface representation of priority op response that extends that waits to commit a layer 1 transaction, including when given on optional confirmation number. +::collapsible + - `waitL1Commit(confirmation?: number)`: `Promise` -Waits for the L1 transaction to be committed, including waiting for the specified number of confirmations. +:: ## `PriorityOpTree` Enumerated list of priority operation tree types. +::collapsible + - Full = `0`, - Rollup = `1`, +:: ## `PriorityQueueType` Enumerated list of priority queue types. +::collapsible + - Deque = `0`, - HeapBuffer = `1`, - Heap = `2`, +:: ## `ProtocolVersion` Interface representation of protocol version. +::collapsible + - `version_id`: `number` - Protocol version ID. - `timestamp`: `number` - Unix timestamp of the version's activation. - `verification_keys_hashes`: `object` - Contains the hashes of various verification keys used in the protocol. - `base_system_contracts`: `object` - Addresses of the base system contracts. - `l2_system_upgrade_tx_hash`: `string | null` - Hash of the transaction used for the system upgrade, if any. +:: ## `RawBlockTransaction` Interface representation of raw block with transactions. +::collapsible + - `common_data` - General information about the L2 transaction. - `L2`: - `nonce`: `number`; @@ -338,6 +422,7 @@ Interface representation of raw block with transactions. - `value`: `bigint`; - `received_timestamp_ms`: `number` - Timestamp when the transaction was received, in milliseconds. - `raw_bytes`: `string` - Raw bytes of the transaction as a hexadecimal string. +:: ## `Signature` @@ -347,15 +432,20 @@ Interface representation of raw block with transactions. Encapsulates the required input parameters for creating a signer for [`SmartAccount`](/sdk/js/ethers/v6/accounts#smartaccount). +::collapsible + - `address`: `string` - Address to which the `SmartAccount` is bound. - `secret`: `any` - Secret in any form that can be used for signing different payloads. - `payloadSigner`: `PayloadSigner` - Custom method for signing different payloads. - `transactionBuilder`: `TransactionBuilder` - Custom method for populating transaction requests. +:: ## `StorageProof` Interface representation of Merkle proofs for storage values. +::collapsible + - `address`: `string` - Account address associated with the storage proofs. - `storageProof` (Array): - Array of objects, each representing a storage proof for the requested keys. - `key`: `string` - Storage key for which the proof is provided. @@ -364,29 +454,38 @@ Interface representation of Merkle proofs for storage values. This index is used to help reconstruct the Merkle path during verification. - `proof`: `string[]` - An array of 32-byte hashes that constitute the Merkle path from the leaf node (representing the storage key-value pair) to the root of the Merkle tree. +:: ## `Token` Interface representation of bridged token. +::collapsible + - `l1Address`: `Address` - Token address on L1. - `l2Address`: `Address` - Token address on L2. - `name`: `string` - Token name. - `symbol`: `string` - Token symbol. - `decimals`: `number` - Token decimals. +:: ## `TransactionBuilder` Populates missing fields in a transaction with default values. +::collapsible + - `transaction`: `TransactionRequest` - The transaction that needs to be populated. - `secret`: `any` - The secret used for populating the transaction. - `provider`: `null | Provider` - The provider is used to fetch data from the network if it is required for signing. +:: ## `TransactionDetails` Interface representation of transaction details. +::collapsible + - `isL1Originated`: `boolean` - Indicates whether the transaction originated on Layer 1. - `status`: `string` - Current status of the transaction (e.g., verified). - `fee`: `BigNumberish` - Transaction fee. @@ -396,6 +495,7 @@ Interface representation of transaction details. - `ethCommitTxHash?`: `string` - Transaction hash of the commit operation. - `ethProveTxHash?`: `string` - Transaction hash of the proof submission. - `ethExecuteTxHash?`: `string` - Transaction hash of the execution. +:: ## `TransactionReceipt` @@ -403,10 +503,13 @@ Interface representation of transaction receipt that extends from Ethers [`providers.TransactionReceipt`](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt) with additional fields. +::collapsible + - `l1BatchNumber`: `number` - The batch number on the L1 network. - `l1BatchTxIndex`: `number` - The transaction index within the batch on the L1 network. - `logs`: `Array` - All logs included in the transaction receipt. - `l2ToL1Logs`: `Array` - The logs of L2 to L1 messages. +:: ## `TransactionRequest` @@ -414,7 +517,10 @@ Interface representation of transaction request that extends from Ethers [`providers.TransactionRequest`](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionRequest) which adds an optional field for EIP-712 transactions. +::collapsible + - `customData?`: `Eip712Meta` - The custom data for EIP712 transaction metadata. +:: ## `TransactionResponse` @@ -422,24 +528,33 @@ Interface representation of transaction response that extends from Ethers [`providers.TransactionResponse`](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionResponse) with additional fields. +::collapsible + - `l1BatchNumber`: `number` - The batch number on the L1 network. - `l1BatchTxIndex`: `number` - The transaction index within the batch on the L1 network. - `wait()`: `Promise` - Waits for transaction to be mined. - `waitFinalize()`: `Promise` - Waits for transaction to be finalized. +:: ## `TransactionStatus` Enumerated list of transaction statuses. +::collapsible + - NotFound = `not-found` - Transaction not found. - Processing = `processing` - Transaction is processing. - Committed = `committed` - Transaction has been committed. - Finalized = `finalized` - Transaction has been finalized. +:: ## `TransactionWithDetailedOutput` Interface representation of transaction with detailed output. +::collapsible + - `transactionHash`: `string` - Transaction hash. - `storageLogs`: `Array` - Storage slots - `events`: `Array` - Generated events. +:: diff --git a/content/sdk/10.js/00.ethers/20.v6/11.migration.md b/content/sdk/10.js/00.ethers/20.v6/11.migration.md index 9d0d10e2..93248124 100644 --- a/content/sdk/10.js/00.ethers/20.v6/11.migration.md +++ b/content/sdk/10.js/00.ethers/20.v6/11.migration.md @@ -1,32 +1,140 @@ --- + title: Migration from `zksync-web3` -description: +description: A guide for migrating from `zksync-web3` to `zksync-ethers v6`. +tags: ["migration", "zksync", "ethers", "web3", "v5 to v6"] --- ::callout{icon="i-heroicons-light-bulb"} Note on v5 and v6 -- This migration notes apply to `zksync-ethers v6`. -- If you're using v5, you don't need to do any changes in your code as `zksync-ethers v5` uses `ethers v5` -similar to the deprecated `zksync-web3`. +- This migration guide applies to `zksync-ethers v6`. +- If you're using v5, no changes are required in your code as `zksync-ethers v5` uses `ethers v5`, similar to the +deprecated `zksync-web3`. :: -This guide provides some high-level differences between `zksync-web3`/`zksync-ethers v5` and `zksync-ethers v6` -for those who are familiar with `zksync-web3` and need a quick primer. `zksync-ethers v6` has several differences -since it's using `ethers.js v6`, compared to `zksync-web3`, which uses `ethers.js v5`. Before continuing to get -to know the changes made in `zksync-ethers`, you should read the -[migration guide](https://docs.ethers.org/v6/migrating/) from `ethers.js v5` to `ethers.js v6`. - -Differences: - -- `Token.Address` has been removed because it was deprecated. -- `Provider.getMessageProof` has been removed because it was deprecated. -- `Provider.getTokenPrice` has been removed because it was deprecated. -- `Provider.getBlockWithTransaction` has been replaced with `Provider.getBlock(, true)`. -- `BlockWithTransaction` has been removed. -- `TransactionRequest.calldata` has been changed from `BytesLike` to `string`. -- `transaction.calldata` parameter in`Provider.estimateL1ToL2Execute` has been changed from `BytesLike` to `string`. -- `transaction.calldata` parameter in `AdaterL1.getRequestExecuteTx` has been changed from `BytesLike` to `string`. -- `transaction.calldata` parameter in `AdapterL1.estimateGasRequestExecute` has been changed from `BytesLike` to `string`. -- `transaction.calldata` parameter in `AdapterL1.RequestExecute` has been changed from `BytesLike` to `string`. -- `utils.parseTransaction` has been replaced by `utils.parseEip712`. +This guide highlights the key differences between `zksync-web3`/`zksync-ethers v5` and `zksync-ethers v6` for those +familiar with `zksync-web3` and need a quick primer. `zksync-ethers v6` incorporates several changes due to its +integration with `ethers.js v6`. Before proceeding, it's recommended to read +the [migration guide](https://docs.ethers.org/v6/migrating/) from `ethers.js v5` to `ethers.js v6`. + +### Key differences + +- **Removal of deprecated functions and properties:** + - `Token.Address` has been removed. + - `Provider.getMessageProof` has been removed. + - `Provider.getTokenPrice` has been removed. + +- **Changes in methods and parameters:** + - `Provider.getBlockWithTransaction` has been replaced with `Provider.getBlock(, true)`. + - `BlockWithTransaction` has been removed. + +- **Changes in transaction parameters:** + - `TransactionRequest.calldata` has been changed from `BytesLike` to `string`. + - `transaction.calldata` parameter in the following methods has been changed from `BytesLike` to `string`: + - `Provider.estimateL1ToL2Execute` + - `AdapterL1.getRequestExecuteTx` + - `AdapterL1.estimateGasRequestExecute` + - `AdapterL1.RequestExecute` + +- **Utilities:** + - `parseTransaction` has been replaced by `Transaction.from`. + +### Migration steps + +1. **Update imports:** + Ensure you're importing from `zksync-ethers` instead of `zksync-web3`. + + ```ts + import { Provider, Wallet, parseEther, Transaction } from "zksync-ethers"; + ``` + +2. **Adapt to method changes:** + Replace deprecated methods with their new counterparts. + + ```ts + // Old + const blockWithTx = await provider.getBlockWithTransaction(blockNumber); + + // New + const blockWithTx = await provider.getBlock(blockNumber, true); + ``` + +3. **Update transaction parameters:** + Change `calldata` parameters from `BytesLike` to `string`. + + ```ts + // Old + const txRequest = { + calldata: ethers.utils.hexlify(data), + }; + + // New + const txRequest = { + calldata: data, + }; + ``` + +4. **Replace utility functions:** + Use the new utility functions provided by `ethers.js v6`. + + ```ts + // Old + const parsedTx = utils.parseTransaction(rawTransaction); + + // New + const parsedTx = Transaction.from(rawTransaction); + ``` + +5. **Remove deprecated properties and methods:** + Ensure you remove any usage of deprecated properties like `Token.Address` and methods such + as `Provider.getMessageProof` and `Provider.getTokenPrice`. + +### Example migration + +#### Before migration (Using `zksync-web3`) + +```ts +import { Provider, Wallet, utils } from "zksync-web3"; +import { ethers } from "ethers"; + +const provider = new Provider("https://mainnet.zksync.io"); +const wallet = new Wallet("", provider); + +const tx = { + to: "0xReceiverAddress", + value: ethers.utils.parseEther("1.0"), + calldata: ethers.utils.hexlify("0x1234"), +}; + +const gasEstimate = await provider.estimateL1ToL2Execute(tx); +console.log(gasEstimate); + +const parsedTx = utils.parseTransaction("0xRawTransaction"); +console.log(parsedTx); +``` + +#### After migration (Using `zksync-ethers v6`) + +```ts +import { Provider, Wallet, parseEther, Transaction } from "zksync-ethers"; + +const provider = new Provider("https://mainnet.zksync.io"); +const wallet = new Wallet("", provider); + +const tx = { + to: "0xReceiverAddress", + value: parseEther("1.0"), + calldata: "0x1234", +}; + +const gasEstimate = await provider.estimateL1ToL2Execute(tx); +console.log(gasEstimate); + +const parsedTx = Transaction.from("0xRawTransaction"); +console.log(parsedTx); +``` + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks. +:: diff --git a/content/sdk/80.troubleshooting.md b/content/sdk/80.troubleshooting.md index 22c823a2..b5ba3c66 100644 --- a/content/sdk/80.troubleshooting.md +++ b/content/sdk/80.troubleshooting.md @@ -17,50 +17,27 @@ correct endpoint for the L2 network is: [ZKsync Sepolia Explorer](%%zk_testnet_b 2. **Transaction hash and block tag**: Use the correct transaction hash and block tag when fetching transaction details. -### Bun +3. **Hardhat installation and module issues in v5**: If you encounter issues with Hardhat, such as missing modules or +deprecation warnings during installation: -If you encounter issues using Bun during the installation, refer to the troubleshooting steps in the table below. +- **Install the missing module**: You must install the required package if an error indicates a missing +module (e.g., `@nomicfoundation/hardhat-toolbox`). Run the following command in your project directory: -##### 1. Network timeout +```sh +npm install @nomicfoundation/hardhat-toolbox +``` -- **Possible cause**: Slow or unstable internet connection -- **Solution**: Increase the timeout duration by using: `curl -fsSL --connect-timeout 60 https://bun.sh/install | bash` +- **Address deprecation warnings**: During installation, you might see deprecation warnings. These warnings +indicate that some packages are outdated but do not necessarily prevent your project from running. You can address +them by updating the respective packages. However, these warnings can be ignored if they do not cause functional issues. -##### 2. Manual download required +- **Run Hardhat**: After installing the required packages, you can verify the installation by running Hardhat: -- **Possible cause**: Automatic download fails -- **Solution**: Manually download the Bun binary from -the [Bun releases page on GitHub](https://github.com/oven-sh/bun/releases/latest). Extract the binary and place it in a -directory that is in your system's PATH. +```sh +npx hardhat +``` -##### 3. Permissions issue +- **Compile the project**: To ensure everything is set up correctly, try compiling your project: -- **Possible cause**: Bun binary is not executable -- **Solution**: Ensure the Bun binary is executable by running: `chmod +x ~/.bun/bin/bun` - -##### 4. PATH not updated - -- **Possible cause**: `~/.bun/bin` not in PATH -- **Solution**: Verify and manually add it to your PATH by editing your shell configuration -file (`~/.zshrc` for zsh): `echo 'export PATH="$HOME/.bun/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc` - -##### 5. TTY initialization failed - -- **Possible cause**: Terminal handling issues or TTY not supported -- **Solution**: Run without TTY by setting the environment variable: `NO_TTY=1 bun install` or disable -telemetry: `export NUXT_TELEMETRY_DISABLED=1` - -##### 6. Telemetry prompt issue - -- **Possible cause**: Nuxt telemetry prompt causing issues -- **Solution**: Set an environment variable to disable the telemetry prompt: `export NUXT_TELEMETRY_DISABLED=1` - -##### 7. Conflicting aliases - -- **Possible cause**: Conflicts with existing aliases or functions -- **Solution**: Ensure there are no conflicting aliases or functions named `bun` by running: `type bun` - -##### 8. Reinitialize shell - -- **Possible cause**: Shell environment not refreshed -- **Solution**: Completely reinitialize your shell environment by starting a new shell session: `exec /bin/zsh` +```sh +npx hardhat compile