Documentation Index
Fetch the complete documentation index at: https://docs.phylax.systems/llms.txt
Use this file to discover all available pages before exploring further.
credible-std is the Solidity standard library for writing, testing, and backtesting 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.
Package and Configuration
credible-std is distributed as a Foundry library.
| Item | Value |
|---|---|
| Repository | phylaxsystems/credible-std |
| Stable dependency | phylaxsystems/[email protected] |
| Development dependency | phylaxsystems/credible-std |
| Foundry remapping | credible-std/=lib/credible-std/src/ |
ffi = true in the relevant Foundry profile:
Core Contracts
| Contract | Purpose |
|---|---|
Assertion.sol | Base contract for assertions. Inherits ForkUtils and StateChanges, exposes trigger helpers, fork ID constructors, call matching helpers, and assertion spec registration. |
Credible.sol | Provides the inherited ph handle for calling the PhEVM precompile. |
PhEvm.sol | Interface for PhEVM cheatcodes, including logs, call inputs, snapshot reads, mapping tracing, ERC20 transfer data, and protection-suite helpers. |
TriggerRecorder.sol | Interface used by Assertion to register assertion triggers. |
SpecRecorder.sol | Defines AssertionSpec and records whether an assertion uses Legacy, Reshiram, or Experimental precompile access. |
StateChanges.sol | Typed helpers for legacy state-change arrays. |
ForkUtils.sol | Helper functions for Reshiram-style snapshot reads and ERC20 balance delta workflows. |
CredibleTest.sol | Forge test base that exposes cl.assertion(...). |
CredibleTestWithBacktesting.sol | Test base for replaying historical transactions against assertions. |
Assertion Helpers
Assertion.sol provides internal helpers for registering when assertion functions run.
Legacy Trigger Helpers
Use these helpers for the launch-era trigger surface: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.
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.
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:| Spec | Meaning |
|---|---|
Legacy | Standard launch precompile set. |
Reshiram | Newer precompile set with explicit snapshot access and legacy-only fork-switching selectors disabled. |
Experimental | Unrestricted access to all available precompiles. May include untested or dangerous behavior. |
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.
CredibleTestWithBacktesting extends the local test base for historical transaction replay. It looks for credible-std/scripts/backtesting/transaction_fetcher.sh; CREDIBLE_STD_PATH overrides the default dependency lookup path.
Related Pages
Cheatcodes API Reference
Full PhEVM cheatcode signatures
Testing Assertions
How to test assertions locally
Backtesting Reference
Backtesting configuration and behavior
Write Your First Assertion
Build a first assertion with credible-std

