Accounts: overview


Accounts: overview

The zkSync Python SDK has a method that generates a signature and a method that verifies messages.

  • sign_typed_data : used to sign EIP712-typed zkSync transactions.
  • verify_typed_data : used to verify the signed EIP712-typed zkSync transactions.

construction

For constructing the instance it needs only account and chain_id.

Example:

from zksync2.signer.eth_signer import PrivateKeyEthSigner
from eth_account import Account
from zksync2.module.module_builder import ZkSyncBuilder


account = Account.from_key("PRIVATE_KEY")
zksync_web3 = ZkSyncBuilder.build("ZKSYNC_NETWORK_URL")

chain_id = zksync_web3.zksync.chain_id
signer = PrivateKeyEthSigner(account, chain_id)

sign_typed_data

The signer is used to generate the signature of the provided transaction based on your account(your private key).

Parameters

ParametersReturn valueDescription
EIP712 Structure, optional domainWeb3 py SignedMessageBuilds SignedMessage based on the encoded in EIP712 format Transaction.

verify_typed_data

It's used to verify the provided transaction, whose signature is added to the final EIP712 transaction for its validation.

Parameters

ParametersReturn valueDescription
signature, EIP712 structure, optional domainboolReturns True if the encoded transaction is signed with provided signature.

The signer class also has the following properties:

AttributeDescription
addressAccount address
domainDomain that is used to generate signature. It depends on chain_id of network.