diff --git a/content/00.build/65.developer-reference/50.era-contracts/20.system-contracts.md b/content/00.build/65.developer-reference/50.era-contracts/20.system-contracts.md index d3c05bf4..44f19447 100644 --- a/content/00.build/65.developer-reference/50.era-contracts/20.system-contracts.md +++ b/content/00.build/65.developer-reference/50.era-contracts/20.system-contracts.md @@ -20,6 +20,7 @@ system upgrade through L1. The addresses and the interfaces of the L2 system contracts can be found [here](https://github.com/matter-labs/era-contracts/blob/main/system-contracts/contracts/Constants.sol). ## SystemContext +**Address:** 0x000000000000000000000000000000000000800b This contract is used to support various system parameters not included in the VM by default, i.e. `chainId`, `origin`, `ergsPrice`, `blockErgsLimit`, `coinbase`, `difficulty`, `baseFee`, `blockhash`, `block.number`, `block.timestamp.` @@ -33,6 +34,7 @@ implementation itself is rather straightforward, but to better understand this c about the [block processing](/build/developer-reference/batches-and-l2-blocks) on ZKsync. ## AccountCodeStorage +**Address:** 0x0000000000000000000000000000000000008002 The code hashes of accounts are stored inside the storage of this contract. Whenever a VM calls a contract with address `address` it retrieves the value under storage slot `address` of this system contract, if this value is non-zero, it @@ -49,6 +51,7 @@ without the `isConstructor` flag, the bytecode of the default account (i.e. EOA original bytecode. ## BootloaderUtilities +**Address:** 0x000000000000000000000000000000000000800c This contract contains some of the methods which are needed purely for the bootloader functionality but were moved out from the bootloader itself for the convenience of not writing this logic in Yul. @@ -65,6 +68,7 @@ wallet users and contracts that call it, i.e. it should not be distinguishable Ethereum. ## Ecrecover +**Address:** 0x0000000000000000000000000000000000000001 The implementation of the ecrecover precompile. It is expected to be used frequently, so written in pure yul with a custom memory layout. @@ -80,6 +84,7 @@ It also validates the input by the same rules as the EVM precompile: After that, it makes a precompile call and returns empty bytes if the call failed, and the recovered address otherwise. ## Empty contracts +**Address:** 0x0000000000000000000000000000000000000000 Some of the contracts are relied upon to have EOA-like behaviour, i.e. they can be always called and get the success value in return. An example of such address is 0 address. We also require the bootloader to be callable so that the @@ -89,6 +94,9 @@ For these contracts, we insert the `EmptyContract` code upon genesis. It is basi and returns `success=1`. ## SHA256 & Keccak256 +**SHA256 Address:** 0x0000000000000000000000000000000000000002 + +**Keccak256 Address:** 0x0000000000000000000000000000000000008010 Note that, unlike Ethereum, keccak256 is a precompile (_not an opcode_) on ZKsync. @@ -105,6 +113,9 @@ the crypto part of the precompiles expects to work with padded data. This means to an unprovable transaction. ## L2BaseToken & MsgValueSimulator +**L2BaseToken Address:** 0x000000000000000000000000000000000000800a + +**MsgValueSimulator Address:** 0x0000000000000000000000000000000000008009 Unlike Ethereum, zkEVM does not have any notion of any special native token. That’s why we have to simulate operations with Ether via two contracts: `L2BaseToken` & `MsgValueSimulator`. @@ -121,6 +132,7 @@ Whenever anyone wants to do a non-zero value call, they need to call `MsgValueSi - Pass the address of the callee in the second extraAbiParam. ## KnownCodeStorage +**Address:** 0x0000000000000000000000000000000000008004 This contract is used to store whether a certain code hash is “known”, i.e. can be used to deploy contracts. On ZKsync, the L2 stores the contract’s code _hashes_ and not the codes themselves. Therefore, it must be part of the protocol to @@ -143,6 +155,7 @@ those code hashes that are known. The KnownCodesStorage contract is also responsible for ensuring that all the “known” bytecode hashes are also valid. ## ContractDeployer & ImmutableSimulator +**Address:** 0x0000000000000000000000000000000000008006 `ContractDeployer` is a system contract responsible for deploying contracts on ZKsync. It is better to understand how it works in the context of how the contract deployment works on ZKsync. Unlike Ethereum, where `create`/`create2` are @@ -216,6 +229,7 @@ struct ImmutableData { basically denoting an array of immutables passed to the contract. ### **Immutables** +**Address:** 0x0000000000000000000000000000000000008005 Immutables are stored in the `ImmutableSimulator` system contract. The way how `index` of each immutable is defined is part of the compiler specification. This contract treats it simply as mapping from index to value for each particular @@ -240,6 +254,7 @@ are not in kernel space and have no contract deployed on them. This address: `success = 1, returndatasize = 0` for calls from anyone except for the bootloader. ## L1Messenger +**Address:** 0x0000000000000000000000000000000000008008 A contract used for sending arbitrary length L2→L1 messages from ZKsync to L1. While ZKsync natively supports a rather limited number of L1→L2 logs, which can transfer only roughly 64 bytes of data a time, we allowed sending @@ -255,6 +270,7 @@ The `L1Messenger` is also responsible for validating the total pubdata to be sen - L1Messenger [Interface](https://github.com/matter-labs/era-contracts/blob/main/system-contracts/contracts/interfaces/IL1Messenger.sol) ## NonceHolder +**Address:** [0x0000000000000000000000000000000000008003](https://explorer.zksync.io/address/0x0000000000000000000000000000000000008003) Serves as storage for nonces for our accounts. Besides making it easier for operator to order transactions (i.e. by reading the current nonces of account), it also serves a separate purpose: making sure that the pair (address, nonce) is @@ -282,6 +298,7 @@ transactions in the mempool. - NonceHolder [Interface](https://github.com/matter-labs/era-contracts/blob/main/system-contracts/contracts/interfaces/INonceHolder.sol) ## EventWriter +**Address:** [0x000000000000000000000000000000000000800d](https://explorer.zksync.io/address/0x000000000000000000000000000000000000800d) A system contract responsible for emitting events. @@ -291,6 +308,7 @@ Generally, the users should not interact with this contract directly, but only t events. ## Compressor +**Address:** [0x000000000000000000000000000000000000800e](https://explorer.zksync.io/address/0x000000000000000000000000000000000000800e) One of the most expensive resource for a rollup is data availability, so in order to reduce costs for the users we compress the published pubdata in several ways: