System Contracts

MegaETH system contracts — addresses, interfaces, preconditions, and usage examples.

MegaETH provides system contracts that give transactions access to functionality beyond the standard EVM.

Contract
Address
Purpose

High-Precision Timestamp

Provides timestamps at microsecond resolution. The timestamp is the moment when the transaction started execution on the sequencer. Useful when block.timestamp (one-second resolution) is not granular enough.

circle-info

This timestamp is published by the sequencer based on its local clock. Using it requires trusting the sequencer to provide accurate time data.

Address: 0x6342000000000000000000000000000000000002

Interface:

interface IHighPrecisionTimestamp {
    /// @notice Returns the current timestamp in microseconds since Unix epoch.
    /// @return Microsecond-precision timestamp, non-decreasing within a block,
    ///         capped at block.timestamp × 1,000,000.
    function timestamp() external view returns (uint256);
}

IHighPrecisionTimestamp hpt = IHighPrecisionTimestamp(
    0x6342000000000000000000000000000000000002
);
uint256 timestampUs = hpt.timestamp(); // microsecond timestamp
uint256 timestampSec = timestampUs / 1_000_000; // convert to second timestamp

Outcome:

  • Returns the current timestamp in microseconds since Unix epoch.

  • Reading the timestamp accesses volatile data and caps the transaction's Compute Gas to 20M. Avoid reading it in transactions that perform heavy computation.

Properties:

Property
Value

Precision

1 μs (1/1,000,000 second)

Range

(previous_block.timestamp × 1,000,000, block.timestamp × 1,000,000]

Monotonicity

Non-decreasing within a block

Snapshot

Stable within a single transaction — repeated reads return the same value

Common use cases: HFT strategies, rate limiting, latency measurements, sub-second auctions, TWAP calculations.

Keyless Deployment

Deploys a contract to a deterministic address using Nick's Method — a technique for deploying to the same address on every EVM chain without holding the deployer's private key.

On MegaETH, the original keyless deployment transaction would run out of gas because code deposit storage gas (10,000 gas/byte) makes deploying even a small contract far more expensive than on Ethereum. This system contract re-executes the original transaction with a caller-supplied gas limit override.

Address: 0x6342000000000000000000000000000000000003

Interface:

Preconditions:

  • keylessDeploymentTransaction must be a valid RLP-encoded Nick's Method deployment transaction: pre-EIP-155, contract creation (to = null), nonce = 0.

  • gasLimitOverride must be ≥ the original transaction's gas limit.

  • The deployment address must not already contain code.

  • The call must carry zero ETH value.

Outcome:

  • On success: returns gasUsed, deployedAddress (the deterministic address), and empty errorData.

  • On deployment failure (e.g., out of gas): the call does not revert. It returns gasUsed, deployedAddress = 0x0, and errorData describing the failure. State changes from the attempted deployment (including gas charges) are still applied.

circle-exclamation
circle-info

Deploying common keyless contracts (e.g., CREATE2 Factory, EIP-1820 Registry) can be expensive due to storage gas. If you need a widely-used contract deployed, reach out to the MegaETH team — it may already be deployed or the team can assist.

Already-deployed contracts (available on MegaETH via KeylessDeploy):

chevron-rightRex4 preview — upcoming system contractshashtag

The following system contracts are planned for the Rex4 hardfork. Addresses and interfaces are subject to change before release.

Contract
Address
Purpose

MegaAccessControl

0x6342000000000000000000000000000000000004

Opt out of volatile data access detection via disableVolatileDataAccess()

MegaLimitControl

0x6342000000000000000000000000000000000005

Query remaining compute gas budget via remainingComputeGas()

Last updated