ph.changedMappingKeys to enumerate written keys and ph.mappingValueDiff to read each entry’s pre- and post-transaction values.
Status
- Supported by the V2 Reshiram assertion specification
- Supported by the V1 assertion specification
Interface
baseSlot is the mapping’s declared storage slot. Each returned key is the encoded mapping-key preimage used to derive keccak256(key ++ baseSlot). For a mapping whose value is a struct, set fieldOffset to the field’s offset from the derived entry slot.
Example
Behavior and Constraints
- Discovery is scoped to entries written by the current transaction. It includes same-value
SSTOREoperations, for whichmappingValueDiffreturnschangedasfalse. - The mapping base slot and any struct field offset must be known.
- Discovery is best effort. Custom inline assembly or precomputed hashed storage slots can prevent the runtime from recovering a key.
- Nested mappings are not discoverable from the outer mapping slot because the outer entry hash is used as the inner base slot rather than written to storage.
Uses
- Validate limits for every balance or position modified by a transaction.
- Reconcile modified entries against aggregate accounting.
- Apply field-specific checks to mapping values stored as structs.

