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.
Choose the assertion specification supported by your target Ethereum deployment. Reshiram (V2) helpers require V2 support in the enforcer; a local test passing does not establish deployment compatibility. Earlier Linea-specific restrictions are documented in L2 Platform Notes.
Package and Configuration
This reference follows source revisionfe49de6. Pin your dependency; a Solidity interface in the library does not establish support in your CLI or deployed enforcer.
The npm package includes raw ABI arrays under
artifacts/, such as artifacts/PhEvm.json and artifacts/protection/safe/SafeTxShapeAssertion.json. Paths mirror src/; additional interfaces in one source file use SourceName.InterfaceName.json. These files contain ABI arrays, not deployment bytecode.
Protocol guards live in credible-registry, separately from this assertion library.
Core Contracts
Assertion Helpers
Assertion.sol provides internal helpers for registering when assertion functions run.
Call, Storage, and Balance Helpers
These helpers predate Reshiram. Storage triggers remain useful for configuration policies; the current Safe configuration assertion uses one.Reshiram Trigger Helpers
Use these helpers for newer trigger types:registerFnCallTrigger pairs with ph.context() so an assertion can inspect the matched call’s selector and call range.
Anomaly Triggers
watchAnomaly(target, fnSelector, sensitivity) registers a check at a sensitivity level from 1 to 10. Sensitivity.RECOMMENDED is level 7. The trigger decides whether to run the assertion; the assertion’s logic decides whether to reject the transaction.
Anomaly dispatch requires runtime support. The released PCL version tested in the anomaly guide does not dispatch these triggers; compiling the interface is insufficient.
Fork and Snapshot Helpers
Reshiram assertions should prefer explicit snapshot IDs over deprecated fork-switching cheatcodes. ConstructForkId values explicitly:
ph.loadStateAt to read storage at those snapshots:
loadStateAt.
A ForkId identifies a snapshot; constructing one does not switch EVM state. Ordinary getter calls and native .balance reads do not become snapshot reads. Use ph.staticcallAt for protocol getters, or these inherited ForkUtils helpers:
The helpers forward 500,000 gas and revert if the snapshot call fails. Typed helpers also revert if the returned bytes cannot be decoded. When calling
ph.staticcallAt directly, check result.ok before decoding result.data.
ERC20 Delta Helpers
ForkUtils.sol also includes ERC20 transfer-delta helpers:
State Change Helpers
StateChanges.sol converts ph.getStateChanges(...) from bytes32[] into typed arrays:
Address, Bool, and Bytes32.
Call Matching Helpers
Assertion.sol includes helpers for querying successful calls through the Reshiram call-matching precompile:
_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:Testing Contracts
CredibleTest is the base contract for tests run with pcl test. It exposes cl.assertion(...), which registers an assertion against a target for the next call and selects one assertion function. This does not reproduce production dispatch of every matching assertion. Use the repository’s optimized ci profile for its protection tests; see gas-limit testing.
Related Pages
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
Writing Your Own Policies
Define, implement, and test policies for your protocol.

