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.
Deterministic cross-chain deployment (Nick's Method)
Opt out of volatile data access detection
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.
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 timestampOutcome:
Returns the current timestamp in microseconds since Unix epoch.
Reading the timestamp accesses volatile data and triggers the 20M compute gas detention cap. Avoid reading it in transactions that perform heavy computation.
Properties:
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:
keylessDeploymentTransactionmust be a valid RLP-encoded Nick's Method deployment transaction: pre-EIP-155, contract creation (to= null), nonce = 0.gasLimitOverridemust 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 emptyerrorData.On deployment failure (e.g., out of gas): the call does not revert. It returns
gasUsed,deployedAddress = 0x0, anderrorDatadescribing the failure. State changes from the attempted deployment (including gas charges) are still applied.
Code deposit costs 10,000 storage gas per byte on MegaETH. A 24 KB contract costs roughly 240M storage gas. If gasLimitOverride is too low for this cost, the inner deployment will fail (out of gas) but the outer call still succeeds — check errorData and deployedAddress. Simulate the transaction with mega-evme to find the required gas — it has no gas cap and fully implements MegaETH's gas model. Alternatively, use eth_estimateGas on a MegaETH endpoint (subject to the RPC compute gas cap).
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):
Mega Access Control
Provides a proactive mechanism to prevent untrusted subcalls from accessing volatile data. A contract can disable volatile data access for its entire call subtree before any untrusted code runs. Attempts to access volatile data while disabled revert immediately, preventing both the access and the detention side effect.
Address: 0x6342000000000000000000000000000000000004
Interface:
Functions are declared view so they can be called from view contexts. The node intercepts these calls and tracks the restriction outside EVM storage, so no state modification occurs.
Outcome:
disableVolatileDataAccess()— disables volatile data access for the caller's call frame and all descendant call frames.enableVolatileDataAccess()— re-enables access, but only if the restriction was set at the caller's own depth. If a parent frame disabled access, the call reverts withDisabledByParent().isVolatileDataAccessDisabled()— returnstrueif volatile data access is currently disabled.
The restriction automatically ends when the call frame that called disableVolatileDataAccess returns. No explicit cleanup is needed.
Use MegaAccessControl when calling untrusted contracts to prevent them from silently triggering gas detention and tightening your gas budget.
Common use cases: DeFi protocols calling untrusted hooks, proxy contracts with user-supplied logic, batch execution of arbitrary calls.
Mega Limit Control
Provides a runtime query for the effective remaining compute gas, accounting for both gas detention and per-call-frame resource budgets. The standard GAS opcode does not reflect these MegaETH-specific constraints.
Address: 0x6342000000000000000000000000000000000005
Interface:
Outcome:
Returns the effective remaining compute gas for the caller's call frame at the time of the call.
The returned value accounts for both the detention cap (if triggered) and the per-call-frame compute gas budget — it is the minimum of the two.
The value is a point-in-time snapshot that decreases as execution proceeds.
Common use cases: Gas-aware batching (loop until budget exhausted), deciding whether to attempt expensive sub-calls, on-chain gas budgeting.
Related Pages
Volatile Data Access — compute gas cap, best practices for reading volatile data
System Contracts (spec) — formal specification of the system contract registry
Oracle (spec) — underlying oracle contract that powers the High-Precision Timestamp and other services
KeylessDeploy (spec) — keyless deployment sandbox and validation rules
MegaAccessControl (spec) — volatile data access restriction mechanism
MegaLimitControl (spec) — remaining compute gas query
Last updated