Skip to content

Commit

Permalink
feat: added pages for L2VoidSigner and L1VoidSinger
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngozi-Txfusion committed Jul 4, 2024
1 parent 4e271fb commit 2752ad4
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---

title: L2VoidSigner
description: A class extending ethers.VoidSigner for Layer 2 operations
tags: ["Ethereum", "Blockchain", "L2", "Signer"]

---

::callout{icon="i-heroicons-light-bulb"}
Methods that are not listed below do not work since they require signing the transaction with the key!
::

A `L2VoidSigner` is an extension of the `ethers.VoidSigner` class providing only L2 (Layer 2) operations.

### Properties

- `provider: Provider`
- The provider instance connected to the L2 network.

### Methods

#### `connect(provider: Provider): L2VoidSigner`

Connects the `L2VoidSigner` to the L2 network using the specified provider.

##### Parameters

- `provider: Provider` - The provider instance for connecting to an L2 network.

##### Returns

- `L2VoidSigner` - A new instance of `L2VoidSigner` connected to the specified provider.

##### Example

```javascript
import { Provider, L2VoidSigner, types } from "zksync-ethers";

const provider = Provider.getDefaultProvider(types.Network.Sepolia);

let signer = new L2VoidSigner("<ADDRESS>");
signer = signer.connect(provider);
```

#### `populateTransaction(tx: TransactionRequest): Promise<TransactionLike>`

Populates a transaction with the necessary fields. The only required fields are `transaction.to` and
either `transaction.data` or `transaction.value` (or both if the method is payable). Other fields will be automatically filled.

##### Parameters

- `tx: TransactionRequest` - The transaction request to be populated.

##### Returns

- `Promise<TransactionLike>` - A promise that resolves to a populated transaction.

##### Example

```javascript
import { Provider, L2VoidSigner, Wallet, types, utils } from "zksync-ethers";

const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const signer = new L2VoidSigner("<ADDRESS>", provider);

const populatedTx = await signer.populateTransaction({
to: Wallet.createRandom().address,
value: 7_000_000n,
maxFeePerGas: 3_500_000_000n,
maxPriorityFeePerGas: 2_000_000_000n,
customData: {
gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
factoryDeps: [],
},
});
```

### Private Methods

::callout{icon="i-heroicons-light-bulb"}
These methods are used internally and are not intended for direct use by consumers of the class.
::

#### `_signerL2(): L2VoidSigner`

Returns the current `L2VoidSigner` instance.

##### Returns

- `L2VoidSigner` - The current instance of `L2VoidSigner`.

#### `_providerL2(): Provider`

Returns the provider connected to the L2 network.

##### Returns

- `Provider` - The provider instance connected to the L2 network.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---

title: L1VoidSigner
description: A class extending ethers.VoidSigner for Layer 1 operations
tags: ["Ethereum", "Blockchain", "L1", "Signer"]

---

::callout{icon="i-heroicons-light-bulb"}
Methods that are not listed below do not work since they require signing the transaction with the key!
::

A `L1VoidSigner` is an extension of the `ethers.VoidSigner` class providing only L1 (Layer 1) operations.

### Properties

- `providerL2?: Provider`
- The provider instance connected to the L2 network (optional).

### Methods

#### `constructor(address: string, providerL1?: ethers.Provider, providerL2?: Provider)`

Creates a new instance of `L1VoidSigner`.

##### Parameters

- `address: string` - The address of the account.
- `providerL1?: ethers.Provider` - The provider instance for connecting to an L1 network.
- `providerL2?: Provider` - The provider instance for connecting to an L2 network (optional).

##### Example

```javascript
import { Provider, L1VoidSigner, types } from "zksync-ethers";
import { ethers } from "ethers";

const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const ethProvider = ethers.getDefaultProvider("sepolia");
const signer = new L1VoidSigner("<ADDRESS>", ethProvider, provider);
```

#### `connect(provider: ethers.Provider): L1VoidSigner`

Connects the `L1VoidSigner` to the L1 network using the specified provider.

##### Parameters

- `provider: ethers.Provider` - The provider instance for connecting to an L1 network.

##### Returns

- `L1VoidSigner` - A new instance of `L1VoidSigner` connected to the specified provider.

##### Example

```javascript
import { L1VoidSigner } from "zksync-ethers";
import { ethers } from "ethers";

const ethProvider = ethers.getDefaultProvider("sepolia");

let signer = new L1VoidSigner("<ADDRESS>");
signer = signer.connect(ethProvider);
```

#### `getBalance(token?: Address, blockTag: BlockTag = 'committed'): Promise<bigint>`

Returns the balance of the account.

##### Parameters

- `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'.

##### Returns

- `Promise<bigint>` - A promise that resolves to the balance of the account.

##### Example

```javascript
import { L1VoidSigner } from "zksync-ethers";
import { ethers } from "ethers";

const ethProvider = ethers.getDefaultProvider("sepolia");

const signer = new L1VoidSigner("<ADDRESS>", ethProvider);
const balance = await signer.getBalance();
```

### Private Methods

::callout{icon="i-heroicons-light-bulb"}
These methods are used internally and are not intended for direct use by consumers of the class.
::

#### `_providerL1(): ethers.Provider`

Returns the provider connected to the L1 network.

##### Returns

- `ethers.Provider` - The provider instance connected to the L1 network.

#### `_signerL1(): L1VoidSigner`

Returns the current `L1VoidSigner` instance.

##### Returns

- `L1VoidSigner` - The current instance of `L1VoidSigner`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---

title: L2VoidSigner
description: A class extending ethers.VoidSigner for Layer 2 operations
tags: ["Ethereum", "Blockchain", "L2", "Signer"]

---

::callout{icon="i-heroicons-light-bulb"}
Methods that are not listed below do not work since they require signing the transaction with the key!
::

A `L2VoidSigner` is an extension of the `ethers.VoidSigner` class providing only L2 (Layer 2) operations.

### Properties

- `provider: Provider`
- The provider instance connected to the L2 network.

### Methods

#### `connect(provider: Provider): L2VoidSigner`

Connects the `L2VoidSigner` to the L2 network using the specified provider.

##### Parameters

- `provider: Provider` - The provider instance for connecting to an L2 network.

##### Returns

- `L2VoidSigner` - A new instance of `L2VoidSigner` connected to the specified provider.

##### Example

```javascript
import { Provider, L2VoidSigner, types } from "zksync-ethers";

const provider = Provider.getDefaultProvider(types.Network.Sepolia);

let signer = new L2VoidSigner("<ADDRESS>");
signer = signer.connect(provider);
```

#### `populateTransaction(tx: TransactionRequest): Promise<TransactionLike>`

Populates a transaction with the necessary fields. The only required fields are `transaction.to` and
either `transaction.data` or `transaction.value` (or both if the method is payable). Other fields will be automatically filled.

##### Parameters

- `tx: TransactionRequest` - The transaction request to be populated.

##### Returns

- `Promise<TransactionLike>` - A promise that resolves to a populated transaction.

##### Example

```javascript
import { Provider, L2VoidSigner, Wallet, types, utils } from "zksync-ethers";

const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const signer = new L2VoidSigner("<ADDRESS>", provider);

const populatedTx = await signer.populateTransaction({
to: Wallet.createRandom().address,
value: 7_000_000n,
maxFeePerGas: 3_500_000_000n,
maxPriorityFeePerGas: 2_000_000_000n,
customData: {
gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
factoryDeps: [],
},
});
```

### Private Methods

::callout{icon="i-heroicons-light-bulb"}
These methods are used internally and are not intended for direct use by consumers of the class.
::

#### `_signerL2(): L2VoidSigner`

Returns the current `L2VoidSigner` instance.

##### Returns

- `L2VoidSigner` - The current instance of `L2VoidSigner`.

#### `_providerL2(): Provider`

Returns the provider connected to the L2 network.

##### Returns

- `Provider` - The provider instance connected to the L2 network.
Loading

0 comments on commit 2752ad4

Please sign in to comment.