bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 13쪽 중 8쪽
000000000000000000000012) |
| `OptimismMintableERC721Factory` | [0x4200000000000000000000000000000000000017](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000017) |
| `ProxyAdmin` | [0x4200000000000000000000000000000000000018](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000018) |
| `SequencerFeeVault` | [0x4200000000000000000000000000000000000011](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000011) |
| `WETH9` | [0x4200000000000000000000000000000000000006](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000006) |
| `SchemaRegistry` | [0x4200000000000000000000000000000000000020](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000020) |
| `EAS` | [0x4200000000000000000000000000000000000021](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000021) |
| `L2Controller` | [0x4200000000000000000000000000000000000100](https://explorer.zircuit.com/address/0x4200000000000000000000000000000000000100) |
## Definitions
### GasPriceOracle
This contract offers an API for querying how large the L1 portion of the transaction fee will be, providing transparency and predictability in fee computation.
#### Functions
`getL1Fee(bytes memory _data)`: Computes the L1 portion of the fee for a given RLP-encoded transaction.
`gasPrice()`: Retrieves the current L2 gas price (base fee).
`baseFee()`: Retrieves the current L2 base fee.
`overhead()`: Retrieves the current fee overhead from the L1Block contract.
`scalar()`: Retrieves the current fee scalar from the L1Block contract.
`l1BaseFee()`: Retrieves the latest known L1 base fee from the L1Block contract.
`decimals()`: Retrieves the number of decimals used in the scalar.
`getL1GasUsed(bytes memory _data)`: Computes the amount of L1 gas used for a given transaction, considering the overhead and padding.
### L1Block
The `L1Block`contract allows users on L2 to access information about the latest L1 block.
### L2CrossDomainMessenger
The `L2CrossDomainMessenger` contract is instrumental in facilitating communication between L1 and L2, allowing for messages to be sent from L2 to L1 and ensuring the validity and safety of these messages. It abstracts lower-level details, providing a more user-friendly interface for developers working with cross-domain communication.
### L2ERC721Bridge
Overall, the `L2ERC721Bridge` contract plays a crucial role in the cross-layer functionality of ERC721 tokens, allowing them to be transferred between L1 and L2 while maintaining the integrity and ownership of the tokens.
The contract acts as a minter for new tokens on L2 when it detects deposits into the L1 ERC721 bridge.
It also acts as a burner for tokens being withdrawn from L2 to L1.
It ensures seamless cross-layer functionality for ERC721 tokens, enabling them to be transferred between Ethereum and Zircuit without losing ownership or metadata.
#### Events
Emits `ERC721BridgeFinalized` when a deposit is finalized on L2.
Emits `ERC721BridgeInitiated` when a withdrawal is initiated from L2.
### L2StandardBridge
This contract manages asset transfers between L2 and L1. For L2-native ERC20 tokens, withdrawals escrow them in this contract, while L1-native ERC20s are burnt on L2. Deposits from L1 to L2 are finalized by minting or releasing assets on L2.
#### Functions:
`withdraw` & `withdrawTo`: Initiate L2 to L1 withdrawals. The contract discerns between ETH and ERC20 withdrawals.
**Limitations:** The contract may not support all ERC20 types, especially those with transfer fees, rebasing, or blocklists.
### L2toL1MessagePasser
This contract serves as the storage and management system for these L2-to-L1 messages, ensuring they are uniquely identified and can be processed on L1.
#### Events:
`MessagePassed`: Triggered when a withdrawal is initiated. Provides details about the message, including the sender, target, value, and the unique withdrawal hash.
#### Functions:
`receive` function that allows users to send ETH directly to it, which in turn initiates a withdrawal.
`initiateWithdrawal`: This is the primary function that users or other contracts will call to send a message from L2 to L1. It constructs a withdrawal message based on parameters like target address on L1, gas limit, data, and the value (ETH amount). The function then computes the hash of this message and stores it in an append-only Merkle tree with root `messageRoot`. An event `MessagePassed` is then emitted with details of the message.
`messageNonce`: Returns the next nonce for a message to be sent. The nonce also embeds the message version in its upper two bytes. This approach ensures that different message structures can be distinguished and handled accordingly in the future.
`isUsedNonceForWithdrawal` : Checks if a nonce was used for withdrawals.
# L2 Precompiles
A special type of smart contract built directly into the EVM that executes common cryptographic operations with greater efficiency than contracts written in high-level languages like Solidity
A special type of smart contract built directly into the EVM that executes common cryptographic operations with greater efficiency than contracts written in high-level languages like Solidity
Note that the support for these precompiles may change as the Zircuit proof system evolves. They should be used with caution. If you have any questions, please reach out via discord.
## EVM Precompiles
List of precompiles for both Zircuit Mainnet and Garfield Testnet:
| Contract Name | Address |
| ----------------------- | ------- |
| ECRecover | 0x01 |
| SHA256 | 0x02 |
| RIPEMD | 0x03 |
| Identity | 0x04 |
| ModExp | 0x05 |
| ECAdd | 0x06 |
| ECScalarMul | 0x07 |
| ECPairing | 0x08 |
| BLAKE2b | 0x09 |
| Point evaluation | 0x0a |
| BLS12\_G1ADD | 0x0b |
| BLS12\_G1MSM | 0x0c |
| BLS12\_G2ADD | 0x0d |
| BLS12\_G2MSM | 0x0e |
| BLS12\_PAIRING\_CHECK | 0x0f |
| BLS12\_MAP\_FP\_TO\_G1 | 0x10 |
| BLS12\_MAP\_FP2\_TO\_G2 | 0x11 |
| P256VERIFY | 0x100 |
# L2 Preinstalls
General use contracts made available to improve Zircuit's UX
General use contracts made available to improve Zircuit's UX
## Zircuit Mainnet & Garfield Testnet
| Contract Name | Contract Address |
| ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [`Safe`](https://github.com/safe-global/safe-smart-account/blob/v1.3.0/contracts/GnosisSafe.sol) | [0x69f4D1788e39c87893C980c06EdF4b7f686e2938](https://explorer.zircuit.com/address/0x69f4D1788e39c87893C980c06EdF4b7f686e2938) |
| [`SafeL2`](https://github.com/safe-global/safe-smart-account/blob/v1.3.0/contracts/GnosisSafeL2.sol) | [0xfb1bffC9d739B8D520DaF37dF666da4C687191EA](https://explorer.zircuit.com/address/0xfb1bffC9d739B8D520DaF37dF666da4C687191EA) |
| [`Multicall3`](https://github.com/mds1/multicall/tree/main) | [0xcA11bde05977b3631167028862bE2a173976CA11](https://explorer.zircuit.com/address/0xcA11bde05977b3631167028862bE2a173976CA11) |
| [`MultiSend`](https://github.com/safe-global/safe-smart-account/blob/v1.3.0/contracts/libraries/MultiSend.sol) | [0x998739BFdAAdde7C933B942a68053933098f9EDa](https://explorer.zircuit.com/address/0x998739BFdAAdde7C933B942a68053933098f9EDa) |
| [`MultiSendCallOnly`](https://github.com/safe-global/safe-smart-account/blob/v1.3.0/contracts/libraries/MultiSendCallOnly.sol) | [0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B](https://explorer.zircuit.com/address/0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B) |
| [`SafeSingletonFactory`](https://github.com/safe-global/safe-singleton-factory/blob/main/source/deterministic-deployment-proxy.yul) | [0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7](https://explorer.zircuit.com/address/0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7) |
| [`DeterministicDeploymentProxy`](https://github.com/Arachnid/deterministic-deployment-proxy) | [0x4e59b44847b379578588920cA78FbF26c0B4956C](https://explorer.zircuit.com/address/0x4e59b44847b379578588920cA78FbF26c0B4956C) |
| [`create2deployer`](https://github.com/pcaversaccio/create2deployer) | [0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2](https://explorer.zircuit.com/address/0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2) |
| [`permit2`](https://github.com/Uniswap/permit2) | [0x000000000022D473030F116dDEE9F6B43aC78BA3](https://explorer.zircuit.com/address/0x000000000022D473030F116dDEE9F6B43aC78BA3) |
| [`ERC-4337 EntryPoint`](https://github.com/eth-infinitism/account-abstraction/blob/v0.6.0/contracts/core/EntryPoint.sol) | [0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789](https://explorer.zircuit.com/address/0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789) |
| [`ERC-4337 SenderCreator`](https://github.com/eth-infinitism/account-abstraction/blob/v0.6.0/contracts/core/SenderCreator.sol) | [0x7fc98430eAEdbb6070B35B39D798725049088348](https://explorer.zircuit.com/address/0x7fc98430eAEdbb6070B35B39D798725049088348) |
# CREATE2 Deployments
In the Ethereum Virtual Machine, `CREATE2` is an opcode that allows for the deployment of smart contracts with deterministic addresses. This is particularly useful in complex decentralized applications (dApps) where the ability to predict the address of a contract before it is deployed can simplify interactions between multiple contracts and improve security.
It is especially valuable in the context of L2, as it enables consistent contract addresses across L1 and L2, simplifying cross-layer interactions.
To facilitate safe usage of the `CREATE2` opcode, there is a `create2deployer` Preinstall deployed on Zircuit, which can be used for deterministic deployment addresses of smart contracts. The Preinstalls are accessible on the addresses specified on [https://github.com/zircuit-labs/docs/blob/main/addresses/preinstalls/broken-reference/README.md](https://github.com/zircuit-labs/docs/blob/main/addresses/preinstalls/broken-reference/README.md "mention").
[create2deployer](https://github.com/pcaversaccio/create2deployer) provides two functions. `computeAddress(bytes32 salt, bytes32 codeHash)` returns the address where a contract will be stored if deployed through the deploy function. The `salt` is a 32-byte value used to add additional entropy to the contract creation process and prevent collisions with the default `CREATE` opcode. The `codeHash` is the *keccak256* hash of the contract's bytecode that will be deployed. This includes the compiled bytecode of the contract itself, potentially combined with any constructor arguments encoded into it. Any change in `salt` or `codeHash` will result in a new address. After computing the address, the `deploy(uint256 value, bytes32 salt, bytes memory code)` function can be used to deploy the contract on the address computed before. The `value` field in the `deploy` function is used to specify the amount of Ether (in wei) that should be sent along with the contract deployment transaction. This parameter serves several purposes:
1. Funding the new contract: If the contract being deployed needs initial Ether to function, this value will be transferred to the new contract's balance upon creation.
2. Payable constructors: If the contract being deployed has a `payable` constructor, this `value` can be used to send Ether to the constructor function during deployment.
The `code` parameter in the `deploy` function should be the complete bytecode including encoded constructor arguments.
Apart from this, some smart contract development tools like Foundry automatically make use of a `CREATE2` Proxy like this and the steps above do not have to be done manually necessarily.
# Architecture
## Introduction
Zircuit is a EVM-compatible zero-knowledge (zk) rollup that delivers robust security guarantees through validity proofs built on proven rollup infrastructure. We combine the battle-tested OP Stack foundation with [OP-Succinct](https://succinctlabs.github.io/op-succinct/) built with a modified version of [Kona](https://github.com/op-rs/kona/tree/main/bin/client) to support [Sequencer-Level Security (SLS)](/info/architecture/sls-deep-dive). SLS represents a distinctive capability that sets Zircuit apart from other networks. This feature proactively examines each transaction prior to block inclusion, detecting and preventing security threats and malicious behavior.
## Core Architecture
Zircuit's architecture is built around three fundamental components that work together to process transactions, generate proofs, and maintain secure interaction with Ethereum Layer 1:
### Sequencer
The sequencer layer is responsible for ordering and batching transactions to construct Layer 2 blocks. Built on the [OP Stack](https://docs.optimism.io/stack/getting-started) infrastructure, sequencers ensure reliable transaction processing and block production while maintaining compatibility with existing Ethereum tooling and development workflows.
### Provers
Zircuit integrates [Succinct's SP1](https://docs.succinct.xyz/docs/sp1/introduction) zkVM to generate zero-knowledge validity proofs for each block. These provers create cryptographic evidence that all transactions in a block have been executed correctly according to the protocol rules, enabling trustless verification without requiring full re-execution of the transactions.
### Smart Contracts
The Layer 1 smart contract infrastructure manages the core protocol functions, including state root updates, proof verification, and withdrawal processing. These contracts serve as the trust anchor between Zircuit's Layer 2 execution environment and Ethereum.
### Key Benefits
The hybrid architecture delivers several advantages over traditional rollup designs:
* **Fast Finality**: Validity proofs provide immediate cryptographic finality without waiting periods
* **No Challenge Period**: Withdrawals can be processed immediately upon proof verification
* **Battle-Tested Foundation**: Built on OP Stack's proven infrastructure for maximum reliability
* **Enhanced Security**: Zero-knowledge proofs provide mathematical guarantees of execution correctness
This documentation will guide you through the technical implementation details, integration patterns, and development workflows for building on Zircuit's rollup architecture.
# Transaction Flow
<figure><img src="https://lh7-us.googleusercontent.com/BGexrJnT4xLpUStqzmCDYeqlSsYVpeKwATjfqFaVyHiO9jB8-05gDHNeCCDs54BJGC1RPXu3-8HQu2C18dfLumU9j7Vszy3oJyR284348-9ze5pRgBnbZ8L4O3E6wiGUSES1Fl5J7CU8nFQUF5LbuWY" alt=""><figcaption><p>Transaction flow of Zircuit</p></figcaption></figure>
Transactions on the rollup may originate from L1 or directly from the L2.
A transaction that originates on the L1 may be a **deposit transaction**, where ETH or other assets are bridged onto the L2, or a **cross domain function call**. An L2 transaction may be a transfer of assets between L2 accounts or a call to a contract deployed on the L2 from an account with funds on the L2. In either case, the transaction is processed by the rollup node, which consists of the sequencer, the execution engine, and the batcher.
The sequencer directs the execution engine as to which transactions should be in a block by adding deposit transactions generated from smart contract events on L1.
The batcher submits L2 transaction batches to the L1, so that users have full data availability. Users can use this data as this is a so-called soft commitment that their transaction is completed. A soft commitment is a commitment that the transaction will be included in the L2 chain, but it is not considered final yet as its execution has not yet been proved.
The execution engine processes the transactions in the batches and results in a new L2 state. The execution engine processes these transactions by putting them in L2 blocks.
These L2 blocks are then processed by Zircuit's zkVM-based proving system using a two-phase approach. In the first phase, Zircuit generates **range proofs** for several L2 blocks using SP1 (Succinct's zkVM) to prove Kona's execution. These range proofs guarantee that each state transition between L2 blocks was executed correctly - that balances are computed properly, smart contract opcodes execute as intended, and so forth. In the second phase, Zircuit performs **aggregate proofs** by verifying and combining multiple range proofs together to maximize the number of L2 transactions that get rolled up in a single L1 proof verification.
The proofs for batches of L2 blocks are verified on Ethereum via a smart contract. After verification succeeds, the L2 state root is updated on the relevant contracts, recording the changes contained in the L2 blocks included in the batch whose proof was just verified. At this time, those L2 blocks are considered final. Withdrawals from the L2 are now possible without an additional delay.
The verification of the validity proof concludes the transaction flow at a glance. The next two sections will dive into the processing of deposit, L2, and withdrawal transactions.
### Deposits and L2 Transactions
This section covers the architecture related to deposits and L2 transactions in greater detail. A deposit transaction bridges assets like Ether or ERC-20 tokens from Ethereum to Zircuit. An L2 transaction is one that originates on Zircuit itself, like a transfer of Ether between accounts, or smart contract calls on Zircuit.
The following image highlights the specific components of Zircuit that are involved in a deposit or L2 transaction.
<figure><img src="https://lh7-us.googleusercontent.com/sS_LHktmy1MuM47qsFDpfuw-6bwRbazb4NykEliU1f8hcImQ6GCQadCRp9_h6ROJGWJc67ie5V_IW0ijeYIgYpxwjXN9HG_pUyCJ3pcFyeY5OUOvvCYHDpf9mvqy-pL0yyEVTRrmcwpBWJck841cDxc" alt=""><figcaption><p>Deposits in Zircuit</p></figcaption></figure>
Deposit transactions are initiated by calling a smart contract on L1. Two contracts can be used to deposit ETH onto Zircuit: the `L1StandardBridge` contract and the `OptimismPortal` smart contract. The `L1StandardBridge` contract can be used to deposit Ether by calling the appropriate function. The `OptimismPortal` contract bridges Ether by implementing the `receive` function, meaning any Ether sent to this contract without specifying a function to call will automatically be bridged.
Only the `L1StandardBridge` can be used to bridge ERC-20 tokens, and ERC-721 tokens can be bridged via the `L1ERC721Bridge` contract.
Transactions that originate on L2 naturally do not need to call these smart contracts. Instead, they are sent to the chain via an RPC call or a wallet and are processed directly by the rollup node.
Once the rollup node observes a deposit or receives an L2 transaction, it constructs blocks that contain those transactions via its sequencer functionality.
The rollup node will create deposit transactions for each deposit event observed on L1 and pass these transactions along with any L2 transactions to the execution engine. The execution engine is a modified version of Geth, which supports the deposit transaction type and other minor changes necessary for rollup operation.
The rollup node also passes the transactions included in the blocks to the batcher service, which posts the transactions and their arguments as `calldata` on the L1, providing full data availability.
At this point, the transaction will be included on the L2 after the provers receive the relevant blocks that contain the transactions; no further interaction from the transaction’s sender is needed.
### Withdrawals
Withdrawal transactions take assets like ETH off of Zircuit and return them to the L1. A withdrawal transaction is initiated by first sending an L2 transaction to the `L2StandardBridge` contract calling the appropriate function.
Once that transaction is included in the L2, the components in the following diagram are relevant to complete the withdrawal transaction.
<figure><img src="프로젝트로 돌아가기