Java API

Smart Account Utilities

Utilities for managing and signing payloads with smart accounts

The Smart Account Utilities in the ZKsync Python SDK provide functions to manage and sign payloads using ECDSA private keys.

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.zksync.get_transaction_count(Web3.to_checksum_address(tx.from_), EthBlockParams.PENDING.value).
  • Populates gas_limit via provider.zksync.zks_estimate_fee(tx.to_zk_transaction()). If tx.from is not EOA,
  • the estimation is done with address derived from the ECDSA private key.
  • Populates chain_id via provider.eth.chain_id.
  • Populates type with EIP_712_TX_TYPE.
  • Populates value if set, otherwise to 0.
  • Populates data with 0x.
  • Populates meta with {factoryDeps=[], gasPerPubdata=50_000}.

Inputs

ParameterTypeDescription
txTransactionThe transaction that needs to be populated.
secretList<String>The ECDSA private keys.
providerZkSyncThe provider which fetches data from the network.
nonce@Nullable BigIntegerThe nonce to be used in transaction, can be null.

SignPayloadWithECDSA

sign

Signs the payload using an ECDSA private key.

Inputs

ParameterTypeDescription
payloadTransaction712The payload that needs to be signed.
secretList<String>The ECDSA private key. Uses only first key in the list.
chainIdlongThe chain id.

SignPayloadWithMultipleECDSA

sign

Signs the payload using multiple ECDSA private keys. The signature is generated by concatenating signatures created by signing with each key individually. The length of the resulting signature should be secrets.length * 65 + 2.

Inputs

ParameterTypeDescription
payloadbytesThe payload that needs to be signed.
secret[HexStr]The list of the ECDSA private keys.
For development and testing, it is recommended to use burner wallets. Avoid using real private keys to prevent security risks.

Made with ❤️ by the ZKsync Community