# base/contracts architecture

> Architecture diagram of the GitHub repository base/contracts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/base/contracts
- Repository: https://github.com/base/contracts

## Overview

This repository contains Base’s smart-contract system and supporting scripts. Its principal user-facing workflow is a transaction or withdrawal moving between Base and Ethereum: the L1 portal handles deposits and withdrawals, L2 contracts pass messages and assets, and proof/dispute contracts support withdrawal finalization. Separate system-configuration and fee components support chain operation. The README identifies the repository as Base contracts but does not document contract-level call paths, and the sampled source excerpts cover tooling rather than these Solidity contracts; therefore the domain connections below are dashed and unverified.

Main entry points: [`src/L1/OptimismPortal2.sol`](https://github.com/base/contracts/blob/main/src/L1/OptimismPortal2.sol) (Optimism Portal), [`src/L1/proofs/DisputeGameFactory.sol`](https://github.com/base/contracts/blob/main/src/L1/proofs/DisputeGameFactory.sol) (Dispute Game Factory), [`src/L1/L1StandardBridge.sol`](https://github.com/base/contracts/blob/main/src/L1/L1StandardBridge.sol) (L1 Standard Bridge), [`src/L2/L2CrossDomainMessenger.sol`](https://github.com/base/contracts/blob/main/src/L2/L2CrossDomainMessenger.sol) (L2 Messenger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_l1["L1 Portal"]
  node_portal["Optimism Portal"]
  node_resource["Resource Metering"]
end

subgraph group_proofs["Withdrawal Proofs"]
  node_gamefactory["Dispute Game Factory"]
  node_anchor["Anchor State"]
  node_aggregate["Aggregate Verifier"]
  node_verifier["Verifier<br/>[Verifier.sol]"]
  node_tee["TEE Verifier<br/>[TEEVerifier.sol]"]
  node_zk["ZK Verifier<br/>[ZKVerifier.sol]"]
end

subgraph group_messaging["Cross-Chain Messaging"]
  node_messenger["Cross-Domain Messenger"]
  node_l1messenger["L1 Messenger"]
  node_l2messenger["L2 Messenger"]
  node_passer["L2 Message Passer"]
end

subgraph group_assets["Bridges and Tokens"]
  node_standardbridge["Standard Bridge<br/>[StandardBridge.sol]"]
  node_l1bridge["L1 Standard Bridge"]
  node_l2bridge["L2 Standard Bridge"]
  node_erc721["ERC721 Bridge<br/>[ERC721Bridge.sol]"]
  node_mintable["Mintable ERC20"]
end

subgraph group_operations["Chain Operations"]
  node_sysconfig["System Config<br/>[SystemConfig.sol]"]
  node_l1block["L1 Block Data<br/>[L1Block.sol]"]
  node_gasoracle["Gas Price Oracle<br/>[GasPriceOracle.sol]"]
  node_feevault["Fee Vaults<br/>[FeeVault.sol]"]
  node_protocolversions["Protocol Versions"]
end

node_user(("User"))
node_ethereum(("Ethereum"))

node_user -.->|"initiates deposit"| node_portal
node_portal -.->|"posts transaction"| node_ethereum
node_ethereum -.->|"proves withdrawal"| node_portal
node_portal -.->|"opens dispute"| node_gamefactory
node_gamefactory -.->|"checks anchor"| node_anchor
node_gamefactory -.->|"requests verification"| node_verifier
node_aggregate -.->|"aggregates proofs"| node_verifier
node_tee -.->|"provides proof"| node_aggregate
node_zk -.->|"provides proof"| node_aggregate
node_user -.->|"sends message"| node_l1messenger
node_l1messenger -.->|"uses shared logic"| node_messenger
node_l2messenger -.->|"uses shared logic"| node_messenger
node_l2messenger -.->|"records withdrawal"| node_passer
node_user -.->|"bridges assets"| node_l1bridge
node_l1bridge -.->|"uses shared bridge"| node_standardbridge
node_l2bridge -.->|"uses shared bridge"| node_standardbridge
node_l1bridge -.->|"coordinates transfer"| node_l2bridge
node_erc721 -.->|"sends bridge messages"| node_l1messenger
node_erc721 -.->|"sends bridge messages"| node_l2messenger
node_mintable -.->|"represents bridged token"| node_l2bridge
node_sysconfig -.->|"configures portal"| node_portal
node_l1block -.->|"supplies L1 data"| node_gasoracle
node_gasoracle -.->|"supports fee accounting"| node_feevault
node_user -.->|"queries versions"| node_protocolversions

click node_portal "https://github.com/base/contracts/blob/main/src/L1/OptimismPortal2.sol"
click node_resource "https://github.com/base/contracts/blob/main/src/L1/ResourceMetering.sol"
click node_gamefactory "https://github.com/base/contracts/blob/main/src/L1/proofs/DisputeGameFactory.sol"
click node_anchor "https://github.com/base/contracts/blob/main/src/L1/proofs/AnchorStateRegistry.sol"
click node_aggregate "https://github.com/base/contracts/blob/main/src/L1/proofs/AggregateVerifier.sol"
click node_verifier "https://github.com/base/contracts/blob/main/src/L1/proofs/Verifier.sol"
click node_tee "https://github.com/base/contracts/blob/main/src/L1/proofs/tee/TEEVerifier.sol"
click node_zk "https://github.com/base/contracts/blob/main/src/L1/proofs/zk/ZKVerifier.sol"
click node_messenger "https://github.com/base/contracts/blob/main/src/universal/CrossDomainMessenger.sol"
click node_l1messenger "https://github.com/base/contracts/blob/main/src/L1/L1CrossDomainMessenger.sol"
click node_l2messenger "https://github.com/base/contracts/blob/main/src/L2/L2CrossDomainMessenger.sol"
click node_passer "https://github.com/base/contracts/blob/main/src/L2/L2ToL1MessagePasser.sol"
click node_standardbridge "https://github.com/base/contracts/blob/main/src/universal/StandardBridge.sol"
click node_l1bridge "https://github.com/base/contracts/blob/main/src/L1/L1StandardBridge.sol"
click node_l2bridge "https://github.com/base/contracts/blob/main/src/L2/L2StandardBridge.sol"
click node_erc721 "https://github.com/base/contracts/blob/main/src/universal/ERC721Bridge.sol"
click node_mintable "https://github.com/base/contracts/blob/main/src/universal/OptimismMintableERC20.sol"
click node_sysconfig "https://github.com/base/contracts/blob/main/src/L1/SystemConfig.sol"
click node_l1block "https://github.com/base/contracts/blob/main/src/L2/L1Block.sol"
click node_gasoracle "https://github.com/base/contracts/blob/main/src/L2/GasPriceOracle.sol"
click node_feevault "https://github.com/base/contracts/blob/main/src/L2/FeeVault.sol"
click node_protocolversions "https://github.com/base/contracts/blob/main/src/L1/ProtocolVersions.sol"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_portal,node_resource,node_user toneBlue
class node_gamefactory,node_anchor,node_aggregate,node_verifier,node_tee,node_zk toneAmber
class node_messenger,node_l1messenger,node_l2messenger,node_passer toneMint
class node_standardbridge,node_l1bridge,node_l2bridge,node_erc721,node_mintable toneRose
class node_sysconfig,node_l1block,node_gasoracle,node_feevault,node_protocolversions,node_ethereum toneIndigo
```

## Components

### L1 Portal

- [Optimism Portal](https://github.com/base/contracts/blob/main/src/L1/OptimismPortal2.sol): `src/L1/OptimismPortal2.sol`
- [Resource Metering](https://github.com/base/contracts/blob/main/src/L1/ResourceMetering.sol): `src/L1/ResourceMetering.sol`

### Withdrawal Proofs

- [Dispute Game Factory](https://github.com/base/contracts/blob/main/src/L1/proofs/DisputeGameFactory.sol): `src/L1/proofs/DisputeGameFactory.sol`
- [Anchor State](https://github.com/base/contracts/blob/main/src/L1/proofs/AnchorStateRegistry.sol): `src/L1/proofs/AnchorStateRegistry.sol`
- [Aggregate Verifier](https://github.com/base/contracts/blob/main/src/L1/proofs/AggregateVerifier.sol): `src/L1/proofs/AggregateVerifier.sol`
- [Verifier](https://github.com/base/contracts/blob/main/src/L1/proofs/Verifier.sol): `src/L1/proofs/Verifier.sol`
- [TEE Verifier](https://github.com/base/contracts/blob/main/src/L1/proofs/tee/TEEVerifier.sol): `src/L1/proofs/tee/TEEVerifier.sol`
- [ZK Verifier](https://github.com/base/contracts/blob/main/src/L1/proofs/zk/ZKVerifier.sol): `src/L1/proofs/zk/ZKVerifier.sol`

### Cross-Chain Messaging

- [Cross-Domain Messenger](https://github.com/base/contracts/blob/main/src/universal/CrossDomainMessenger.sol): `src/universal/CrossDomainMessenger.sol`
- [L1 Messenger](https://github.com/base/contracts/blob/main/src/L1/L1CrossDomainMessenger.sol): `src/L1/L1CrossDomainMessenger.sol`
- [L2 Messenger](https://github.com/base/contracts/blob/main/src/L2/L2CrossDomainMessenger.sol): `src/L2/L2CrossDomainMessenger.sol`
- [L2 Message Passer](https://github.com/base/contracts/blob/main/src/L2/L2ToL1MessagePasser.sol): `src/L2/L2ToL1MessagePasser.sol`

### Bridges and Tokens

- [Standard Bridge](https://github.com/base/contracts/blob/main/src/universal/StandardBridge.sol): `src/universal/StandardBridge.sol`
- [L1 Standard Bridge](https://github.com/base/contracts/blob/main/src/L1/L1StandardBridge.sol): `src/L1/L1StandardBridge.sol`
- [L2 Standard Bridge](https://github.com/base/contracts/blob/main/src/L2/L2StandardBridge.sol): `src/L2/L2StandardBridge.sol`
- [ERC721 Bridge](https://github.com/base/contracts/blob/main/src/universal/ERC721Bridge.sol): `src/universal/ERC721Bridge.sol`
- [Mintable ERC20](https://github.com/base/contracts/blob/main/src/universal/OptimismMintableERC20.sol): `src/universal/OptimismMintableERC20.sol`

### Chain Operations

- [System Config](https://github.com/base/contracts/blob/main/src/L1/SystemConfig.sol): `src/L1/SystemConfig.sol`
- [L1 Block Data](https://github.com/base/contracts/blob/main/src/L2/L1Block.sol): `src/L2/L1Block.sol`
- [Gas Price Oracle](https://github.com/base/contracts/blob/main/src/L2/GasPriceOracle.sol): `src/L2/GasPriceOracle.sol`
- [Fee Vaults](https://github.com/base/contracts/blob/main/src/L2/FeeVault.sol): `src/L2/FeeVault.sol`
- [Protocol Versions](https://github.com/base/contracts/blob/main/src/L1/ProtocolVersions.sol): `src/L1/ProtocolVersions.sol`

### Other components

- **User**
- **Ethereum**

## Connections

- User → Optimism Portal: initiates deposit
- Optimism Portal → Ethereum: posts transaction
- Ethereum → Optimism Portal: proves withdrawal
- Optimism Portal → Dispute Game Factory: opens dispute
- Dispute Game Factory → Anchor State: checks anchor
- Dispute Game Factory → Verifier: requests verification
- Aggregate Verifier → Verifier: aggregates proofs
- TEE Verifier → Aggregate Verifier: provides proof
- ZK Verifier → Aggregate Verifier: provides proof
- User → L1 Messenger: sends message
- L1 Messenger → Cross-Domain Messenger: uses shared logic
- L2 Messenger → Cross-Domain Messenger: uses shared logic
- L2 Messenger → L2 Message Passer: records withdrawal
- User → L1 Standard Bridge: bridges assets
- L1 Standard Bridge → Standard Bridge: uses shared bridge
- L2 Standard Bridge → Standard Bridge: uses shared bridge
- L1 Standard Bridge → L2 Standard Bridge: coordinates transfer
- ERC721 Bridge → L1 Messenger: sends bridge messages
- ERC721 Bridge → L2 Messenger: sends bridge messages
- Mintable ERC20 → L2 Standard Bridge: represents bridged token
- System Config → Optimism Portal: configures portal
- L1 Block Data → Gas Price Oracle: supplies L1 data
- Gas Price Oracle → Fee Vaults: supports fee accounting
- User → Protocol Versions: queries versions
