Python API

SmartAccount Factories

ECDSASmartAccount and MultisigECDSASmartAccount for SmartAccount.

ECDSASmartAccount

A ECDSASmartAccount is a factory which creates a SmartAccount instance that uses single ECDSA key for signing payload.

create

Creates a SmartAccount instance that uses a single ECDSA key for signing payload.

Inputs

ParameterTypeDescription
addressHexStrThe account address.
secretHexStrThe ECDSA private key.
providerWeb3The provider to connect to.

Example

from eth_account import Account
from eth_account.signers.local import LocalAccount
from web3 import Web3

from zksync2.account.smart_account import SmartAccount, ECDSASmartAccount
from zksync2.module.module_builder import ZkSyncBuilder

if __name__ == "__main__":
  ZKSYNC_PROVIDER = "https://sepolia.era.zksync.dev"

  zksync = ZkSyncBuilder.build(ZKSYNC_PROVIDER)

  account = ECDSASmartAccount.create(multisig_address, [private_key_1, private_key_2], self.zksync)

MultisigECDSASmartAccount

A MultisigECDSASmartAccount is a factory which creates a SmartAccount instance that uses multiple ECDSA keys for signing payloads. The signature is generated by concatenating signatures created by signing with each key individually.

create

Creates a SmartAccount instance that uses multiple ECDSA keys for signing payloads.

Inputs

ParameterTypeDescription
addressstringThe account address.
secret[HexStr]The list of the ECDSA private keys.
providerWeb3The provider to connect to.

Example

from eth_account import Account
from eth_account.signers.local import LocalAccount
from web3 import Web3

from zksync2.account.smart_account import SmartAccount, MultisigECDSASmartAccount
from zksync2.module.module_builder import ZkSyncBuilder

if __name__ == "__main__":
  ZKSYNC_PROVIDER = "https://sepolia.era.zksync.dev"

  zksync = ZkSyncBuilder.build(ZKSYNC_PROVIDER)

  account = MultisigECDSASmartAccount.create(multisig_address, [private_key_1, private_key_2], self.zksync)

Made with ❤️ by the ZKsync Community