Pre-auditThree days of senior audit time for $1,500, credited in full toward your Zealynx audit.3 audit days, credited toward your auditSee how →

ERC-7201

A standard for namespaced storage that places a group of contract state variables at a slot derived from a unique string identifier, so different code sharing the same storage cannot collide.

ERC-7201 defines where a contract keeps its state when more than one piece of code may share the same storage. Instead of letting variables fall into sequential slots starting at slot 0, the contract groups them in a struct and stores that struct at a root slot computed from a namespace id:

1keccak256(abi.encode(uint256(keccak256("example.main")) - 1)) & ~bytes32(uint256(0xff))

The namespace is documented on the struct with a NatSpec annotation, @custom:storage-location erc7201:<id>, so tools can check the layout. Subtracting 1 means the slot has no known hash preimage, and clearing the last byte aligns the location to a 256-slot boundary.

The pattern matters wherever code changes but storage stays. In upgradeable proxies, it lets an implementation and its base contracts keep their state apart. Under EIP-7702 it matters even more: an account can re-delegate to entirely different code, and the new delegate inherits every slot the old one wrote. A delegate that keeps an owner or guardian in slot 0 may read a value it never set, a storage collision. A delegate that keeps its state in its own ERC-7201 namespace starts from slots no other delegate wrote.

Need expert guidance on ERC-7201?

Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.

Get a Quote