Skip to main content
New to cheatcodes? Start with What are Cheatcodes? to understand what they are and why they exist.
This reference lists the Credible Layer cheatcodes exposed through 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 ForkId snapshot 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.
As of May 6, 2026, the v2 Reshiram spec is not live on Linea mainnet. Do not assume Reshiram-only precompiles or onFnCall and onTxEnd triggers are available on Linea mainnet until that rollout is live.

Assertion Specs

credible-std defines assertion specs in SpecRecorder.sol.
Register the spec in the assertion constructor:

Common Types

ForkId

Identifies an immutable transaction snapshot.
Construct 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.
Use 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.
Use 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.
Prefer the opcode-specific functions below when you need to avoid double counting through proxies.

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.
The returned array includes the initial value as the first element. The length is either 0 or at least 2.

State Change Helpers

StateChanges.sol provides typed helpers for reading slot changes as common Solidity types.
The helper family also includes mapping-key and mapping-key-with-offset variants.

getAssertionAdopter

Returns the assertion adopter contract address associated with the current transaction.
This cheatcode is available in 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.
Import it from credible-std/Console.sol.

Legacy Trigger Registration

Legacy trigger registration functions are internal helpers on Assertion.

registerCallTrigger

Registers an assertion function to run when the adopter receives a call.
The one-argument overload triggers on any call to the adopter. The two-argument overload triggers on calls matching triggerSelector.

registerStorageChangeTrigger

Registers an assertion function to run when adopter storage changes.
The one-argument overload triggers on any storage slot change. The two-argument overload triggers on a specific slot.

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. In credible-sdk, these live under crates/assertion-executor/src/inspectors/precompiles/reshiram/.

State Access

loadStateAt

Reads a storage slot from a snapshot fork.
The first overload reads from the current assertion adopter. The second overload reads from any target account.

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.
This reverts outside an assertion function triggered by 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.
This is a best-effort trace heuristic. Custom assembly or precomputed hashed slots can produce false negatives.

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 on Assertion.

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

Do not use these cheatcodes in new assertions. They mutate the active fork globally and are replaced by Reshiram’s explicit ForkId-based loadStateAt API.

forkPreTx

Switches the active fork to the state before the assertion-triggering transaction.
Use loadStateAt(..., _preTx()) instead.

forkPostTx

Switches the active fork to the state after the assertion-triggering transaction.
Use loadStateAt(..., _postTx()) instead.

forkPreCall

Switches the active fork to the state before a specific call execution.
Use loadStateAt(..., PhEvm.ForkId({forkType: 2, callIndex: id})) instead.

forkPostCall

Switches the active fork to the state after a specific call execution.
Use loadStateAt(..., PhEvm.ForkId({forkType: 3, callIndex: id})) instead.

load(address, bytes32)

Loads a storage slot from an address on the current active fork.
Use loadStateAt(target, slot, fork) instead.

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