Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added some missing pages and update errors in zksync ethers v5 and v6 #64

Merged
merged 14 commits into from
Jul 3, 2024
Next Next commit
feat: added some missing pages and update errors in zksync ethers
Ngozi-Txfusion committed Jul 1, 2024

Verified

This commit was signed with the committer’s verified signature.
shikanime Shikanime Deva
commit 6654ae2a57cb5072ce412a9906f8041c5b662eee
Original file line number Diff line number Diff line change
@@ -6,19 +6,45 @@ tags: ["zksync", "web3", "provider", "integration"]

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:

- [`Provider`](/sdk/js/ethers/api/v5/provider/web3provider): 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.
- [`Provider`](/sdk/js/ethers/api/v5/provider/web3provider): 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`](/sdk/js/ethers/api/v5/provider/web3provider): Extends the ZKsync
Era [`Provider`](/sdk/js/ethers/api/v5/provider/provider) class to make it more compatible
with Web3 wallets.
Era [`Provider`](/sdk/js/ethers/api/v5/provider/providers) class to make it more compatible with Web3 wallets.

::callout{icon="i-heroicons-light-bulb"}
Use the [`Web3Provider`](/sdk/js/ethers/api/v5/provider/web3provider) for browser integrations.
::

## Overview

A Web3 Provider is an abstraction used to interact with the blockchain network, allowing applications to send
transactions, query blockchain data, and listen to events. Providers serve as the bridge between the application and
the blockchain, ensuring smooth communication and functionality.

### `Provider`

The `Provider` class in `zksync-ethers` library extends the `ethers.providers.JsonRpcProvider` with additional
ZKsync-specific methods. This allows users to leverage the familiar ethers.js interface while accessing advanced
features specific to ZKsync.

#### Key features

- **JSON-RPC support**: Provides a robust and flexible interface to interact with the blockchain via JSON-RPC.
- **ZKsync methods**: Includes additional methods unique to ZKsync, enhancing functionality and integration capabilities.

### `Web3Provider`

The `Web3Provider` class extends the ZKsync Era `Provider` class to offer enhanced compatibility with Web3 wallets,
making it ideal for browser-based integrations. This provider ensures seamless interaction with wallet extensions like
MetaMask, enabling users to manage their accounts and sign transactions directly from the browser.

#### Key features

- **Web3 compatibility**: Integrates smoothly with popular Web3 wallets, ensuring user-friendly interactions.
- **Enhanced security**: Leverages the security features of Web3 wallets to manage private keys and sign transactions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
---
title: Web3providers
description: Web3 provider objects for integrating with ZKsync.
title: Web3Providers
description: Web3Provider objects for integrating with ZKsync.
tags: ["zksync", "web3", "providers", "integration"]
---



Use this provider for Web3 browser wallet integrations for easy compatibility with Metamask,
WalletConnect, and other popular browser wallets.

Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
---
title: Introduction
description: Manage accounts and sign transactions in zksync-ethers.
tag: ["zksync", "account management", "wallet creation", "transaction signing", "cryptocurrency", "Ethereum"]
tags: ["zksync", "account management", "wallet creation", "transaction signing", "cryptocurrency", "ethereum"]
---

`zksync-ethers` exports the following classes that can sign transactions on ZKsync:

- `Wallet` class is an extension of the `ethers.Wallet` with additional ZKsync features.
- `EIP712Signer` class that is used to sign `EIP712`_-typed_ ZKsync transactions.
- `EIP712Signer` class that is used to sign `EIP712`-typed ZKsync transactions.
- `Signer` and `L1Signer` classes, which should be used for browser integration.
- `VoidSigner` and `L1VoidSigner` classes, which should be used for designed to allow an address to
be used in any API which accepts a `Signer`, but for which there are no credentials available to
perform any actual signing.
- `SmartAccount` which provides better support for account abstraction. There are following factory classes:
- `VoidSigner` and `L1VoidSigner` classes, which are designed to allow an address to be used in any API that accepts
a `Signer`, but for which there are no credentials available to perform any actual signing.
- `SmartAccount` which provides better support for account abstraction. There are the following factory classes:
- `ECDSASmartAccount`: uses a single ECDSA key for signing payload.
- `MultisigECDSASmartAccount`: uses multiple ECDSA keys for signing payloads.

## Overview

The account management system in `zksync-ethers` aims to solve the complexities associated with handling keys, signing
transactions, and performing additional operations on behalf of an account. This system provides a robust and secure
way to manage accounts, ensuring seamless interaction with the ZKsync network.

### Why use these classes?

These classes provide essential functionalities to interact with the ZKsync blockchain, making it easier to manage
accounts, sign transactions, and integrate with web applications. They offer:

- **Security**: Ensures that private keys are securely managed and transactions are signed safely.
- **Convenience**: Simplifies the process of creating and managing accounts, especially with features like account
abstraction and multi-signature support.
- **Compatibility**: Extends existing classes from `ethers.js`, making it easier to integrate with existing projects.

### `Wallet`

The `Wallet` class in `zksync-ethers` extends the `ethers.Wallet` class, providing additional methods specific to
ZKsync. It allows you to create and manage wallets, sign transactions, and interact with the ZKsync network seamlessly.

### `EIP712Signer`

The `EIP712Signer` class is used to sign `EIP712`-typed ZKsync transactions, ensuring that transactions comply with
the EIP-712 standard for typed data.

### `Signer` and `L1Signer`

These classes should be used for browser integration, enabling seamless interaction with web3 wallets like
MetaMask. They extend the basic signer functionalities to support the ZKsync-specific operations.

### `VoidSigner` and `L1VoidSigner`

These classes are designed to allow an address to be used in any API that accepts a `Signer`, but without credentials to
perform any actual signing. They are useful for scenarios where you need to represent an account without exposing its
private keys.

### `SmartAccount`

The `SmartAccount` class provides better support for account abstraction, allowing for more advanced account
management features. There are factory classes for creating instances of `SmartAccount` with different signing methods.

#### `ECDSASmartAccount`

Uses a single ECDSA key for signing payloads.

#### `MultisigECDSASmartAccount`

Uses multiple ECDSA keys for signing payloads.
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ tags: ["zksync", "wallet", "integration", "creation", "management"]
| 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/api/v5/provider/provider) | A ZKsync node provider. Needed for interaction with ZKsync. |
| `providerL2?` | [`Provider`](/sdk/js/ethers/api/v5/provider/providers) | 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
@@ -117,7 +117,7 @@ by either passing it to the constructor or with the `connect` method.

| Parameter | Type | Description |
| ---------- | ------------------------------------- | ----------------------- |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/provider) | A ZKsync node provider. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/providers) | A ZKsync node provider. |

```ts
Wallet.connect(provider:Provider): Wallet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: L1Signer
description: L1Signer object for ZKsync-related operations on Layer 1.
description: L1Signer object for ZKsync on Layer 1.
tags: ["zksync", "L1Signer", "layer 1", "integration", "Ethereum"]
---

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: EIP712Signer
description: How to integrate EIP712Signer with ZKsync and ethers.js
description: EIP712Signer with ZKsync and ethers.js
tags: ["zksync", "ethers.js", "blockchain", "EIP712", "smart contracts"]
---

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: SmartAccount
description: Managing and signing transactions with a SmartAccount in ZKsync.
tags: ["zksync", "SmartAccount", "account management", "wallet creation", "transaction signing"]
description: Managing and signing transactions with a SmartAccount
tags: ["zksync", "smartaccount", "account management", "wallet creation", "transaction signing"]
---

A `SmartAccount` is a signer which can be configured to sign various payloads using a provided secret.
@@ -23,7 +23,7 @@ and [`populateTransactionECDSA`](/sdk/js/ethers/api/v5/utilities/smart-account-u
| Parameter | Type | Description |
| ---------- | ----------------------------------------------------- | --------------------------------------------------- |
| `signer` | [`SmartAccountSigner`](/sdk/js/ethers/api/v5/types#smartaccountsigner) | Contains necessary properties for signing payloads. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/provider) | The provider to connect to (optional). |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/providers) | The provider to connect to (optional). |

```ts
constructor(signer: SmartAccountSigner, provider: Provider)
@@ -49,7 +49,7 @@ Creates a new instance of `SmartAccount` connected to a provider.

| Parameter | Type | Description |
| ---------- | ------------------------------------- | ---------------------------------------------- |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/provider) | The provider to connect the `SmartAccount` to. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/providers) | The provider to connect the `SmartAccount` to. |

```ts
connect(provider: Provider): SmartAccount
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: SmartAccount Factories
description: Using ECDSASmartAccount and MultisigECDSASmartAccount with ECDSA key signing.
tags: ["Smartaccount", "ecdsa", "multisig", "zksync", "ethers.js"]
description: ECDSASmartAccount and MultisigECDSASmartAccount for SmartAccount.
tags: ["smartaccount", "ecdsa", "multisig", "zksync", "ethers.js"]
---

## `ECDSASmartAccount`
@@ -19,7 +19,7 @@ Creates a `SmartAccount` instance that uses a single ECDSA key for signing paylo
| ---------- | ------------------------------------- | --------------------------- |
| `address` | `string` | The account address. |
| `secret` | `string` or `ethers.utils.SigningKey` | The ECDSA private key. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/provider) | The provider to connect to. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/providers) | The provider to connect to. |

```ts
static create(address: string, secret: string | utils.SigningKey, provider: Provider): SmartAccount
@@ -53,7 +53,7 @@ Creates a `SmartAccount` instance that uses multiple ECDSA keys for signing payl
| ---------- | ------------------------------------------ | ----------------------------------- |
| `address` | `string` | The account address. |
| `secret` | `string[]` or `ethers.utils.SigningKeyp[]` | The list of the ECDSA private keys. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/provider) | The provider to connect to. |
| `provider` | [`Provider`](/sdk/js/ethers/api/v5/provider/providers) | The provider to connect to. |

```ts
static create(address: string, secret: string[] | utils.SigningKey[], provider: Provider): SmartAccount
Loading