Ethersv6 API

L2VoidSigner

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

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.

Made with ❤️ by the ZKsync Community