Skip to main content
Storage lookup mappings describe how assertions can read raw storage slots from a target contract when a public getter is not available.

Status

  • Supported
  • Partially Supported
  • Not Supported Yet

Implementation Details

Required Cheatcodes

  • loadStateAt(address target, bytes32 slot, ForkId fork) - Reads the raw storage value at the given slot for the specified contract address and snapshot

Example Implementation

Protocol:
Assertion:

Implementation Notes

  • Storage access capabilities:
    • You can load specific slots from any address, even if no public getter exists
    • Works with both external and internal contract storage

Example Use Cases

  • Read slots of private inputs where no getter is available:
    • e.g. implementation address of ERC1967
  • Access internal contract state for validation
  • Verify ownership or admin privileges properly set

Implementation Considerations

  1. State snapshot semantics:
    • Values can only be read from pre or post states of the executed transactions
    • No access to intermediate state changes during transaction execution
    • To work around this, use getStateChanges() to capture all intermediate values
  2. Storage layout knowledge:
    • Requires understanding of the target contract’s storage layout
    • May need complex casting for packed storage slots

Future Improvements

  • Provide intra-transaction snapshot states
  • Add helper functions for common storage patterns
  • Implement automatic storage layout detection