# Overview

This page specifies the system-contract registry and the protocol-level rules that apply to system contracts in MegaETH. It defines the system-contract set.

## Specification

### Distinction from Precompiles

Both [precompiles](https://docs.megaeth.com/spec/megaevm/precompiles) and system contracts reside at fixed addresses and provide protocol-level functionality, but they differ in a fundamental way:

* **Precompiles** are stateless and pure. They perform a deterministic computation on their input and return output without reading or writing on-chain state. The EVM handles precompile calls entirely outside normal bytecode execution.
* **System contracts** are stateful. They have deployed bytecode, maintain persistent storage, and participate in normal EVM state access (including `SLOAD`, `SSTORE`, and account balance). Some of their functions are subject to [call interception](https://docs.megaeth.com/spec/system-contracts/interception) for protocol-level side effects, but the contracts themselves exist as ordinary accounts with code and storage.

### Stable Registry

A node MUST recognize the following contracts as system contracts:

| Contract                                                                                            | Address                            | Since                                                             | Purpose                              |
| --------------------------------------------------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------- | ------------------------------------ |
| [Oracle](https://docs.megaeth.com/spec/system-contracts/oracle)                                     | `ORACLE_CONTRACT_ADDRESS`          | [MiniRex](https://docs.megaeth.com/spec/network-upgrades/minirex) | Off-chain data key-value storage     |
| [High-Precision Timestamp](https://docs.megaeth.com/spec/system-contracts/high-precision-timestamp) | `HIGH_PRECISION_TIMESTAMP_ADDRESS` | [MiniRex](https://docs.megaeth.com/spec/network-upgrades/minirex) | Sub-second timestamp oracle service  |
| [KeylessDeploy](https://docs.megaeth.com/spec/system-contracts/keyless-deploy)                      | `KEYLESS_DEPLOY_ADDRESS`           | [Rex2](https://docs.megaeth.com/spec/network-upgrades/rex2)       | Deterministic cross-chain deployment |
| [MegaAccessControl](https://docs.megaeth.com/spec/system-contracts/mega-access-control)             | `MEGA_ACCESS_CONTROL_ADDRESS`      | [Rex4](https://docs.megaeth.com/spec/network-upgrades/rex4)       | Volatile-data access control         |
| [MegaLimitControl](https://docs.megaeth.com/spec/system-contracts/mega-limit-control)               | `MEGA_LIMIT_CONTROL_ADDRESS`       | [Rex4](https://docs.megaeth.com/spec/network-upgrades/rex4)       | Query remaining compute-gas budget   |

### Deployment Semantics

System contracts MUST be available at their specified addresses when the corresponding spec is active. Their availability is gated by [spec](https://docs.megaeth.com/spec/hardfork-spec) activation.

### Call Interception

Some system-contract functions are handled at the EVM level rather than exclusively by contract bytecode. The generic interception mechanism — when it fires, how selectors are matched, how calls that do not match fall through to bytecode, and the gas and call-scheme rules — is specified on the [Call Interception](https://docs.megaeth.com/spec/system-contracts/interception) page.

Each system-contract page defines which of its functions are intercepted and what each interception does:

* [Oracle — `sendHint`](https://docs.megaeth.com/spec/oracle#hint-forwarding): performs a side effect (hint forwarding), then falls through to bytecode.
* [KeylessDeploy — `keylessDeploy`](https://docs.megaeth.com/spec/keyless-deploy#interception-scope): intercepted at depth 0; executes deployment in a sandbox instead of on-chain bytecode.
* [MegaAccessControl](https://docs.megaeth.com/spec/mega-access-control#interception-scope): all three functions are fully intercepted.
* [MegaLimitControl](https://docs.megaeth.com/spec/mega-limit-control#interception-scope): `remainingComputeGas` is fully intercepted.

### Backward Compatibility Rule

Any change to system-contract semantics, bytecode-visible interface behavior, or interception rules MUST be introduced by a new spec. Stable behavior for an already-activated spec MUST remain unchanged.

## Constants

| Constant                           | Value                                        | Description                                     |
| ---------------------------------- | -------------------------------------------- | ----------------------------------------------- |
| `ORACLE_CONTRACT_ADDRESS`          | `0x6342000000000000000000000000000000000001` | Stable Oracle system-contract address           |
| `HIGH_PRECISION_TIMESTAMP_ADDRESS` | `0x6342000000000000000000000000000000000002` | Stable high-precision timestamp wrapper address |
| `KEYLESS_DEPLOY_ADDRESS`           | `0x6342000000000000000000000000000000000003` | Stable KeylessDeploy system-contract address    |
| `MEGA_ACCESS_CONTROL_ADDRESS`      | `0x6342000000000000000000000000000000000004` | MegaAccessControl address                       |
| `MEGA_LIMIT_CONTROL_ADDRESS`       | `0x6342000000000000000000000000000000000005` | MegaLimitControl address                        |

## Spec History

* [MiniRex](https://docs.megaeth.com/spec/network-upgrades/minirex) introduced the Oracle and High-Precision Timestamp contracts.
* [Rex2](https://docs.megaeth.com/spec/network-upgrades/rex2) introduced KeylessDeploy.
* [Rex4](https://docs.megaeth.com/spec/network-upgrades/rex4) — added MegaAccessControl and MegaLimitControl contracts.
