New to cheatcodes? Start with What are Cheatcodes? to understand what they are and why they exist.
credible-std.
Cheatcodes are grouped by API status:
- Legacy precompiles: launch-era APIs that remain part of the legacy assertion surface.
- Reshiram precompiles: newer APIs based on explicit
ForkIdsnapshot reads, call context, richer log and call inspection, and protection-suite helpers. - Deprecated cheatcodes: legacy fork-switching APIs. Do not use them in new assertions.
Assertion Specs
credible-std defines assertion specs in SpecRecorder.sol.
| Spec | Availability |
|---|---|
Legacy | Standard launch precompile set. Reshiram-only precompiles are unavailable. |
Reshiram | Reshiram precompiles plus the non-deprecated shared surface. Legacy-only fork-switching selectors are unavailable. |
Experimental | Unrestricted access to all available precompiles. May include untested or dangerous behavior. |
Common Types
ForkId
Identifies an immutable transaction snapshot.
forkType | Snapshot |
|---|---|
0 | PreTx |
1 | PostTx |
2 | PreCall(callIndex) |
3 | PostCall(callIndex) |
ForkId values explicitly:
Log
Represents an Ethereum log emitted during transaction execution.
LogQuery
Filters logs by emitter and signature.
address(0) matches any emitter. bytes32(0) matches any topic0 signature.
CallInputs
Represents call input data recorded during transaction execution.
id with call-scoped APIs such as PhEvm.ForkId({forkType: 2, callIndex: id}), PhEvm.ForkId({forkType: 3, callIndex: id}), callinputAt(id), callOutputAt(id), and getLogsForCall(query, id).
Legacy Precompiles
Legacy precompiles are the standard launch-era cheatcodes. Some are still useful, but prefer the Reshiram equivalents when you need explicit snapshot selection or call-scoped behavior.getLogs
Returns all logs emitted during the assertion-triggering transaction.
getLogsQuery(query, fork) when you need emitter or signature filtering, or getLogsForCall(query, callId) when you need call-scoped logs.
getAllCallInputs
Gets call inputs for a target and selector across CALL, STATICCALL, DELEGATECALL, and CALLCODE.
getCallInputs
Gets call inputs for CALL opcodes only.
getStaticCallInputs
Gets call inputs for STATICCALL opcodes only.
getDelegateCallInputs
Gets call inputs for DELEGATECALL opcodes only.
getCallCodeInputs
Gets call inputs for CALLCODE opcodes only.
Internal Solidity calls are not EVM calls and are not recorded by the call tracer. Calls made through
this.someFunction() are external calls and can be recorded.getStateChanges
Returns the sequence of values for a storage slot during transaction execution.
0 or at least 2.
State Change Helpers
StateChanges.sol provides typed helpers for reading slot changes as common Solidity types.
getAssertionAdopter
Returns the assertion adopter contract address associated with the current transaction.
triggers() and assertion functions. It is not available in the constructor because assertion contracts have no state during deployment.
console.log
Prints debug information during local assertion testing.
credible-std/Console.sol.
Legacy Trigger Registration
Legacy trigger registration functions are internal helpers onAssertion.
registerCallTrigger
Registers an assertion function to run when the adopter receives a call.
triggerSelector.
registerStorageChangeTrigger
Registers an assertion function to run when adopter storage changes.
registerBalanceChangeTrigger
Registers an assertion function to run when the adopter’s ETH balance changes.
Reshiram Precompiles
Reshiram precompiles use explicit snapshot reads instead of global fork switching. Incredible-sdk, these live under crates/assertion-executor/src/inspectors/precompiles/reshiram/.
State Access
loadStateAt
Reads a storage slot from a snapshot fork.
staticcallAt
Executes a read-only call against a snapshot fork.
data contains return data when ok is true and revert data when ok is false.
Logs
getLogsQuery
Returns logs matching an emitter/signature query from a snapshot fork.
getLogsForCall
Returns logs matching a query from one recorded call frame.
Call Inspection
callinputAt
Returns the raw calldata for a traced call.
callOutputAt
Returns the raw return or revert bytes for a traced call.
matchingCalls
Returns recorded calls matching target, selector, and filter criteria.
callType uses 0 for any, 1 for CALL, 2 for STATICCALL, 3 for DELEGATECALL, and 4 for CALLCODE.
Trigger Context
context
Returns context for the current registerFnCallTrigger invocation.
registerFnCallTrigger.
ERC20 Introspection
Erc20TransferData
Decoded ERC20 Transfer event data.
getErc20Transfers
Returns decoded ERC20 transfers for one token in a snapshot fork.
getErc20TransfersForTokens
Returns decoded ERC20 transfers across multiple tokens in a snapshot fork.
changedErc20BalanceDeltas
Returns all transfer records involving a token in a snapshot fork.
reduceErc20BalanceDeltas
Aggregates transfers into net balance deltas per unique (from, to) pair.
Mapping Tracing
changedMappingKeys
Returns canonical Solidity key encodings for mapping entries written during the transaction.
mappingValueDiff
Returns pre-transaction and post-transaction values for one mapping entry.
Transaction Object
getTxObject
Returns data from the original assertion-triggering transaction.
Protection Suite Helpers
forbidChangeForSlot
Checks that one adopter storage slot was not modified.
forbidChangeForSlots
Checks that none of the listed adopter storage slots were modified.
conserveBalance
Checks that an account’s ERC20 balance is unchanged between two forks.
oracleSanity
Checks oracle price consistency across all fork points.
oracleSanityAt
Checks oracle price consistency between two specific forks.
assetsMatchSharePrice
Checks ERC4626 share price consistency across all fork points.
assetsMatchSharePriceAt
Checks ERC4626 share price consistency between two forks.
Circuit Breaker Context
outflowContext
Returns context for an assertion triggered by watchCumulativeOutflow.
inflowContext
Returns context for an assertion triggered by watchCumulativeInflow.
Math Helpers
mulDivDown
Computes (x * y) / denominator, rounded down, using 512-bit intermediates.
mulDivUp
Computes (x * y) / denominator, rounded up, using 512-bit intermediates.
normalizeDecimals
Scales an amount from one decimal base to another.
ratioGe
Compares two ratios with basis-point tolerance.
Reshiram Trigger Registration
Reshiram trigger registration functions are internal helpers onAssertion.
registerFnCallTrigger
Registers an assertion that fires once per matching adopter call. Use ph.context() inside the assertion to inspect the matched call context.
registerTxEndTrigger
Registers an assertion that fires once after the transaction completes.
registerErc20ChangeTrigger
Registers an assertion that fires when a token’s balances change.
watchCumulativeOutflow
Registers a circuit breaker trigger for cumulative ERC20 outflow from the assertion adopter.
thresholdBps is measured against the TVL snapshot taken at the start of the rolling window. 1000 is 10%.
watchCumulativeInflow
Registers a circuit breaker trigger for cumulative ERC20 inflow into the assertion adopter.
thresholdBps is measured against the TVL snapshot taken at the start of the rolling window. 1000 is 10%.
Deprecated Cheatcodes
forkPreTx
Switches the active fork to the state before the assertion-triggering transaction.
loadStateAt(..., _preTx()) instead.
forkPostTx
Switches the active fork to the state after the assertion-triggering transaction.
loadStateAt(..., _postTx()) instead.
forkPreCall
Switches the active fork to the state before a specific call execution.
loadStateAt(..., PhEvm.ForkId({forkType: 2, callIndex: id})) instead.
forkPostCall
Switches the active fork to the state after a specific call execution.
loadStateAt(..., PhEvm.ForkId({forkType: 3, callIndex: id})) instead.
load(address, bytes32)
Loads a storage slot from an address on the current active fork.
loadStateAt(target, slot, fork) instead.
Related Pages
Cheatcodes Overview
Conceptual overview of cheatcodes
Write Your First Assertion
Tutorial for writing an assertion
Use Case Mappings
Examples of assertion capabilities
Testing Assertions
How to test assertions locally

