Ethersv5 API

L1VoidSigner

A class extending ethers.VoidSigner for Layer 1 operations
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.

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.
Example
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
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
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

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.

Made with ❤️ by the ZKsync Community