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
fromusing the address derived from the ECDSA private key. - Populates
nonceviaprovider.zksync.get_transaction_count(Web3.to_checksum_address(tx.from_), EthBlockParams.PENDING.value). - Populates
gas_limitviaprovider.zksync.zks_estimate_fee(tx.to_zk_transaction()). Iftx.fromis not EOA, - the estimation is done with address derived from the ECDSA private key.
- Populates
chain_idviaprovider.eth.chain_id. - Populates
typewithEIP_712_TX_TYPE. - Populates
valueif set, otherwise to0. - Populates
datawith0x. - Populates
metawith{factoryDeps=[], gasPerPubdata=50_000}.
Inputs
| Parameter | Type | Description |
|---|---|---|
tx | Transaction | The transaction that needs to be populated. |
secret | List<String> | The ECDSA private keys. |
provider | ZkSync | The provider which fetches data from the network. |
nonce | @Nullable BigInteger | The nonce to be used in transaction, can be null. |
SignPayloadWithECDSA
sign
Signs the payload using an ECDSA private key.
Inputs
| Parameter | Type | Description |
|---|---|---|
payload | Transaction712 | The payload that needs to be signed. |
secret | List<String> | The ECDSA private key. Uses only first key in the list. |
chainId | long | The 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
| Parameter | Type | Description |
|---|---|---|
payload | bytes | The 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.