Populates missing properties meant for signing using an ECDSA private key:
from
nonce
provider.getTransactionCount(tx.from, "pending")
gasLimit
provider.estimateGas(tx)
tx.from
chainId
provider.getNetwork()
type
utils.EIP712_TX_TYPE
value
bigint
0n
data
0x
customData
{factoryDeps=[], gasPerPubdata=utils.DEFAULT_GAS_PER_PUBDATA_LIMIT}
Requires provider to be set.
provider
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); Copy
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);
Optional
The ECDSA private key used for populating the transaction.
The provider is used to fetch data from the network if it is required for signing.
Populates missing properties meant for signing using an ECDSA private key:
from
using the address derived from the ECDSA private key.nonce
viaprovider.getTransactionCount(tx.from, "pending")
.gasLimit
viaprovider.estimateGas(tx)
. Iftx.from
is not EOA, the estimation is done with address derived from the ECDSA private key.chainId
viaprovider.getNetwork()
.type
withutils.EIP712_TX_TYPE
.value
by converting tobigint
if set, otherwise to0n
.data
with0x
.customData
with{factoryDeps=[], gasPerPubdata=utils.DEFAULT_GAS_PER_PUBDATA_LIMIT}
.Throws
Requires
provider
to be set.Example