Skip to main content
credible-std is the Solidity standard library for writing and testing Credible Layer assertions. It provides the base assertion contract, the ph interface for PhEVM cheatcodes, trigger registration helpers, snapshot-read helpers, typed state-change helpers, and Forge test utilities. For individual cheatcode signatures, see the Cheatcodes API Reference. For local assertion tests, see Testing Assertions.
The current Phylax app and Linea deployment support the V1 assertion specification. pcl warns when an assertion uses the V2 Reshiram specification. Use Reshiram-only helpers for local or development workflows until the target deployment supports V2.

Package and Configuration

credible-std is distributed as a Foundry library.

Core Contracts

Assertion Helpers

Assertion.sol provides internal helpers for registering when assertion functions run.

Legacy Trigger Helpers

Use these helpers for the pre-Reshiram trigger APIs:

Reshiram Trigger Helpers

Use these helpers for newer trigger types:
The cumulative flow helpers collect inflow or outflow into one bucket per block and evaluate those per-block buckets over the configured rolling window. registerFnCallTrigger pairs with ph.context() so an assertion can inspect the matched call’s selector and call range.

Fork and Snapshot Helpers

Reshiram assertions should prefer explicit snapshot IDs over deprecated fork-switching cheatcodes. Construct ForkId values explicitly:
Use ph.loadStateAt to read storage at those snapshots:
For packed storage or mappings, calculate the exact slot before calling loadStateAt.

ERC20 Delta Helpers

ForkUtils.sol also includes ERC20 transfer-delta helpers:
Use these helpers when an assertion needs to reason about ERC20 flows within a selected transaction or call snapshot.

State Change Helpers

StateChanges.sol converts ph.getStateChanges(...) from bytes32[] into typed arrays:
Each helper also has overloads for mapping keys and mapping keys with slot offsets:
The same overload pattern exists for Address, Bool, and Bytes32.

Call Matching Helpers

Assertion.sol includes helpers for querying successful calls through the Reshiram call-matching precompile:
Use _matchingCalls when an assertion needs a bounded list of successful calls to a target selector.

Assertion Spec Helper

Register the desired assertion spec in the constructor:
Available specs:

Testing Contracts

CredibleTest is the base contract for local Forge tests. It exposes cl.assertion(...), which registers an assertion against a target contract for the next transaction in a test.

Cheatcodes API Reference

Full PhEVM cheatcode signatures

Testing Assertions

How to test assertions locally

Review Backtesting Results

Review the automatic backtest attached to a platform release

Write Your First Assertion

Build a first assertion with credible-std