Expand description
ZKsync types: essential type definitions for ZKsync network.
zksync_types
is a crate containing essential ZKsync network types, such as transactions, operations and
blockchain primitives.
Re-exports§
pub use l1::L1TxCommonData;
pub use l2::L2TxCommonData;
pub use protocol_upgrade::ProtocolUpgrade;
pub use protocol_upgrade::ProtocolVersion;
pub use tx::Execute;
pub use storage::*;
Modules§
- abi
- aggregated_
operations - api
- base_
token_ ratio - basic_
fri_ types - Basic types for FRI prover.
- blob
- block
- bytecode
- Bytecode-related types and utils.
- commitment
- Data structures that have more metadata than their primary versions declared in this crate.
For example, L1 batch defined here has the
root_hash
field which is absent inL1BatchHeader
. - debug_
flat_ call - eip712_
signature - This is implementation of a standard for hashing typed structured data for EIP-712 signing standard.
- eth_
sender - ethabi
- Ethereum ABI encoding decoding library.
- fee
- fee_
model - hasher
- helpers
- l1
- Definition of ZKsync network priority operations: operations initiated from the L1.
- l2
- l2_
to_ l1_ log - network
- The network where the ZKsync resides.
- packed_
eth_ signature - priority_
op_ onchain_ data - protocol_
upgrade - protocol_
version - prover_
dal - Types exposed by the prover DAL for general-purpose use.
- pubdata_
da - Types related to data availability.
- secrets
- serde_
wrappers - Generic
serde
helpers. - settlement
- snapshots
- storage
- system_
contracts - tee_
types - tokens
- transaction_
request - tx
transactions
is module that holds the essential information for every transaction.- url
- utils
- vm
- Basic VM types that shared widely enough to not put them in the
multivm
crate. - web3
- Selected Web3 types copied from the
web3
crate. - zk_
evm_ types
Structs§
- Account
Tree Id - Account place in the global state tree is uniquely identified by its address. Binary this type is represented by 160 bit big-endian representation of account address.
- Bloom
- Bloom hash type with 256 bytes (2048 bits) size.
- Eip712
Domain - Encoded
Structure Member - H64
- H128
- Fixed-size uninterpreted hash type with 16 bytes (128 bits) size.
- H160
- Fixed-size uninterpreted hash type with 20 bytes (160 bits) size.
- H256
- Fixed-size uninterpreted hash type with 32 bytes (256 bits) size.
- H512
- Fixed-size uninterpreted hash type with 64 bytes (512 bits) size.
- H520
- Input
Data - Optional input
Ethereum
-like encoded transaction if submitted via Web3 API. If exists, its hash will be used to identify transaction. Note, that for EIP712-type transactions,hash
is not equal to the hash of thedata
, but rather calculated by special formula. - K256
Private Key - secp256k1 private key wrapper.
- L1Batch
Number - ZKsync L1 batch sequential index.
- L1Block
Number - Ethereum network block sequential index.
- L1Chain
Id - ChainId in the Ethereum network.
IMPORTANT: Please, use this method when exactly the L1 chain id is required.
Note, that typically this is not the case and the majority of methods need to work
with settlement layer chain id, which is represented by
SLChainId
. - L2Block
Number - ZKsync network block sequential index.
- L2Chain
Id - ChainId in the ZKsync network.
- Nonce
- ZKsync account nonce.
- Packed
EthSignature - Struct used for working with Ethereum signatures created using eth_sign (using geth, ethers.js, etc)
message is serialized as 65 bytes long
0x
prefixed string. - Priority
OpId - Unique identifier of the priority operation in the ZKsync network.
- SLChain
Id - ChainId of a settlement layer.
- Signature
- Signature encoded as RSV components
- Transaction
- Transaction
Time Range Constraint - U64
- Little-endian large integer type Unsigned 64-bit integer.
- U128
- Little-endian large integer type 128-bit unsigned integer.
- U256
- Little-endian large integer type 256-bit unsigned integer.
Enums§
- Bloom
Input - Deserialize
Error - Execute
Transaction Common - Protocol
Version Id ProtocolVersionId
is a unique identifier of the protocol version. Note, that it is an identifier of theminor
semver version of the protocol, with themajor
version being0
. Also, the protocol version on the contracts may contain potential minor versions, that may have different contract behavior (e.g. Verifier), but it should not impact the users.
Constants§
- EIP_
712_ TX_ TYPE - Denotes the first byte of the special ZKsync’s EIP-712-signed transaction.
- EIP_
1559_ TX_ TYPE - Denotes the first byte of the
EIP-1559
transaction. - EIP_
2930_ TX_ TYPE - Denotes the first byte of the
EIP-2930
transaction. - EIP_
4844_ TX_ TYPE - Denotes the first byte of the
EIP-4844
transaction. - LEGACY_
TX_ TYPE - Denotes the first byte of some legacy transaction, which type is unknown to the server.
- PRIORITY_
OPERATION_ L2_ TX_ TYPE - Denotes the first byte of the priority transaction.
- PROTOCOL_
UPGRADE_ TX_ TYPE - Denotes the first byte of the protocol upgrade transaction.
Traits§
- EIP712
Typed Structure - Interface for defining the structure for the EIP712 signature.
- Struct
Builder - Interface that collects members of the structure into the structure of the EIP-712 standard.
- Struct
Member
Functions§
- address_
to_ h256 - address_
to_ u256 - ceil_
div_ u256 - Computes
ceil(a / b)
. - h256_
to_ address - Converts
H256
value into anAddress
. - h256_
to_ u256 - parse_
h160 - Parses H160 from a slice of bytes.
- parse_
h256 - Parses H256 from a slice of bytes.
- parse_
h256_ opt - Parses H256 from an optional slice of bytes.
- public_
to_ address - Convert public key into the address
- recover
- Recovers the public key from the signature for the message
- sign
- Signs message with the given secret key. Returns the corresponding signature.
- u256_
to_ address - Converts
U256
value into anAddress
. - u256_
to_ h256