Skip to main content

calculateErc8042(keccak256: Function, id: string): Uint8Array

Calculates a storage slot using the ERC-8042 (Diamond Storage) formula: keccak256(id). Simpler than ERC-7201, used primarily by the EIP-2535 Diamond Standard. Parameters:
  • keccak256: (data: Uint8Array) => Uint8Array - Keccak256 hash function
  • id: string - Storage namespace identifier
Returns: Uint8Array - 32-byte storage slot Example:
Defined in: src/primitives/Storage/calculateErc8042.js

Formula

Simple single hash of the namespace identifier. No byte manipulation or decrementation.

Usage Patterns

Diamond Standard Storage

Legacy Diamond Implementations

When to Use ERC-8042

Use ERC-8042 when:
  • Implementing EIP-2535 Diamond Standard
  • Compatibility with existing diamond contracts required
  • Following established diamond patterns
  • Simpler formula preferred
Use ERC-7201 when:
  • General upgradeable proxy patterns
  • Need related storage slots (last byte cleared)
  • Maximum collision resistance required
  • Not tied to diamond standard

Comparison with ERC-7201

Diamond Standard Integration

See Also