Assertion Specifications
- Legacy (V1) exposes the original PhEVM precompiles, including mutable fork switching with
forkPreTx,forkPostTx, andforkPostCall. - Reshiram (V2) replaces mutable fork switching with immutable
ForkIdsnapshot reads and adds newer transaction and call inspection precompiles.
How Assertions Work
Triggers select assertion functions for relevant transaction activity. PhEVM executes them against state snapshots. A participating builder excludes a candidate if an active production assertion fails.Example: Compare Ownership at Transaction Boundaries
What They Can Do That Regular Solidity Can’t
Assertions can read state before and after a transaction or matched call. They can inspect interactions across contracts and check their combined effects. Rules execute offchain with separate gas limits. Teams can update policy without changing protocol logic, once the required Ethereum guard is installed. See Cheatcodes for state access.Common Use Cases
Policies can restrict administrative changes, token outflows, price deviations, and accounting violations. See the Catalog.Constraints
The assertion gas budget is configured by the target runtime. Confirm that budget for the deployment you are testing; a local test runner or EVM block gas limit is a separate setting. Exceeding the limit invalidates the candidate. Use scoped triggers and test the maximum expected workload. See Gas Limits in Testing.Policies for Historical Exploits
The exploit case studies discuss candidate policy checks against historical attacks. Read each example’s implementation status, enforcement assumptions, and replay evidence before treating it as demonstrated prevention.Next Steps
Writing Your Own Policies
Define, implement, and test policies for your protocol.
Cheatcodes
Tools available for writing assertions
Triggers
Learn about assertion triggers and optimization
Use Cases Book
Real-world examples and implementations

