Skip to main content
New to EVM state? Start with Fundamentals for guided examples and Merkle Patricia Trie concepts.

Type Definition

Composite key primitive uniquely identifying storage locations in the Ethereum Virtual Machine by combining contract address with storage slot.
StorageKey combines a 20-byte contract address with a 256-bit storage slot number, enabling efficient tracking of contract state across multiple contracts in a single VM instance.

Quick Reference

    API Methods

    Constructors

    • StorageKey() - Factory function creating storage key from address and slot
    • from() - Universal constructor from various inputs

    Serialization

    Comparison & Type Guards

    • equals() - Compare two storage keys for equality
    • is() - Type guard checking if value is StorageKey

    Utilities

    Types

    Main type combining contract address with storage slot. Design rationale:
    • Each contract has 2^256 storage slots
    • Each slot stores 256-bit value
    • Slots initially zero, consume gas on first write

    Usage Patterns

    Basic Storage Operations

    String Serialization

    Storage Slot Computation

    Multi-Contract State

    Type Guards

    Tree-Shaking

    Import only what you need for optimal bundle size:

    Core Documentation

    API Methods

    • Address - Contract address type
    • Uint - 256-bit unsigned integers for slot values
    • Keccak256 - Keccak256 hashing for state roots

    Specification