Function 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.
  • Populates chainId via provider.getNetwork().
  • Populates type with utils.EIP712_TX_TYPE.
  • Populates value by converting to bigint if set, otherwise to 0n.
  • Populates data with 0x.
  • Populates customData with {factoryDeps=[], gasPerPubdata=utils.DEFAULT_GAS_PER_PUBDATA_LIMIT}.

Requires provider to be set.

import { populateTransactionECDSA, types, Web3ZKsyncL2 } from "web3-plugin-zksync";

const PRIVATE_KEY = "<PRIVATE_KEY>";

const provider = Web3ZKsyncL2.initWithDefaultProvider(types.Network.Sepolia);

const populatedTx = populateTransactionECDSA(
{
chainId: 270,
to: "<RECEIVER>",
value: 7_000_000_000,
},
PRIVATE_KEY,
provider
);