# ZKRollup



> ZKRollup

This contract maintains essential data for zk rollup, including: 1. a list of pending messages, which will be relayed to layer 2; 2. the block tree generated by layer 2 and it&#39;s status.

*the message queue is not used yet, the offline relayer only use events in `L1ScrollMessenger`.*

## Methods

### batches

```solidity
function batches(bytes32) external view returns (bytes32 batchHash, bytes32 parentHash, uint64 batchIndex, bool verified)
```

Mapping from batch id to batch struct.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| batchHash | bytes32 | undefined |
| parentHash | bytes32 | undefined |
| batchIndex | uint64 | undefined |
| verified | bool | undefined |

### blocks

```solidity
function blocks(bytes32) external view returns (bytes32 parentHash, bytes32 transactionRoot, uint64 blockHeight, uint64 batchIndex, bytes32 messageRoot)
```

Mapping from block hash to block struct.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| parentHash | bytes32 | undefined |
| transactionRoot | bytes32 | undefined |
| blockHeight | uint64 | undefined |
| batchIndex | uint64 | undefined |
| messageRoot | bytes32 | undefined |

### commitBatch

```solidity
function commitBatch(IZKRollup.Layer2Batch _batch) external nonpayable
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| _batch | IZKRollup.Layer2Batch | undefined |

### finalizeBatchWithProof

```solidity
function finalizeBatchWithProof(bytes32 _batchId, uint256[] _proof, uint256[] _instances) external nonpayable
```

finalize commited batch in layer 1

*will add more parameters if needed.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| _batchId | bytes32 | The identification of the commited batch. |
| _proof | uint256[] | The corresponding proof of the commited batch. |
| _instances | uint256[] | Instance used to verify, generated from batch. |

### finalizedBatches

```solidity
function finalizedBatches(uint256) external view returns (bytes32)
```

Mapping from batch index to finalized batch id.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | undefined |

### getL2MessageRoot

```solidity
function getL2MessageRoot(bytes32 _blockHash) external view returns (bytes32)
```

Return the merkle root of L2 message tree.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _blockHash | bytes32 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | undefined |

### importGenesisBlock

```solidity
function importGenesisBlock(IZKRollup.Layer2BlockHeader _genesis) external nonpayable
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| _genesis | IZKRollup.Layer2BlockHeader | undefined |

### initialize

```solidity
function initialize(uint256 _chainId) external nonpayable
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| _chainId | uint256 | undefined |

### isBlockFinalized

```solidity
function isBlockFinalized(bytes32 _blockHash) external view returns (bool)
```

Return whether the block is finalized by block hash.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _blockHash | bytes32 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bool | undefined |

### isBlockFinalized

```solidity
function isBlockFinalized(uint256 _blockHeight) external view returns (bool)
```

Return whether the block is finalized by block height.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _blockHeight | uint256 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bool | undefined |

### lastFinalizedBatchID

```solidity
function lastFinalizedBatchID() external view returns (bytes32)
```

The latest finalized batch id.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | undefined |

### layer2ChainId

```solidity
function layer2ChainId() external view returns (uint256)
```

The chain id of the corresponding layer 2 chain.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | undefined |

### layer2GasLimit

```solidity
function layer2GasLimit(uint256) external view returns (uint256)
```

Return the layer 2 block gas limit.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | undefined |

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | undefined |

### operator

```solidity
function operator() external view returns (address)
```

The address of operator.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | address | undefined |

### owner

```solidity
function owner() external view returns (address)
```



*Returns the address of the current owner.*


#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | address | undefined |

### renounceOwnership

```solidity
function renounceOwnership() external nonpayable
```



*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*


### revertBatch

```solidity
function revertBatch(bytes32 _batchId) external nonpayable
```

revert a pending batch.

*one can only revert unfinalized batches.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| _batchId | bytes32 | The identification of the batch. |

### transferOwnership

```solidity
function transferOwnership(address newOwner) external nonpayable
```



*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| newOwner | address | undefined |

### updateOperator

```solidity
function updateOperator(address _newOperator) external nonpayable
```

Update the address of operator.

*This function can only called by contract owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| _newOperator | address | The new operator address to update. |

### version

```solidity
function version() external view returns (string)
```

the current contract version.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | string | undefined |



## Events

### CommitBatch

```solidity
event CommitBatch(bytes32 indexed _batchId, bytes32 _batchHash, uint256 _batchIndex, bytes32 _parentHash)
```

Emitted when a new batch is commited.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _batchId `indexed` | bytes32 | undefined |
| _batchHash  | bytes32 | undefined |
| _batchIndex  | uint256 | undefined |
| _parentHash  | bytes32 | undefined |

### FinalizeBatch

```solidity
event FinalizeBatch(bytes32 indexed _batchId, bytes32 _batchHash, uint256 _batchIndex, bytes32 _parentHash)
```

Emitted when a batch is finalized.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _batchId `indexed` | bytes32 | undefined |
| _batchHash  | bytes32 | undefined |
| _batchIndex  | uint256 | undefined |
| _parentHash  | bytes32 | undefined |

### OwnershipTransferred

```solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| previousOwner `indexed` | address | undefined |
| newOwner `indexed` | address | undefined |

### RevertBatch

```solidity
event RevertBatch(bytes32 indexed _batchId)
```

Emitted when a batch is reverted.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _batchId `indexed` | bytes32 | undefined |

### UpdateOperator

```solidity
event UpdateOperator(address _oldOperator, address _newOperator)
```

Emitted when owner updates address of operator



#### Parameters

| Name | Type | Description |
|---|---|---|
| _oldOperator  | address | The address of old operator. |
| _newOperator  | address | The address of new operator. |



