Skip to content

Instantly share code, notes, and snippets.

@mudgen
Last active March 2, 2026 21:39
Show Gist options
  • Select an option

  • Save mudgen/c3c7d3f0b9a963e090d91576c59519df to your computer and use it in GitHub Desktop.

Select an option

Save mudgen/c3c7d3f0b9a963e090d91576c59519df to your computer and use it in GitHub Desktop.
pragma solidity ^0.8.0;
/**
* @title ERC721Registry
* @notice A registry contract for tracking ERC721 contracts.
* Allows adding ERC721 contract addresses up to a configurable limit.
* @dev EIP-8042 Diamond Storage is used to organize and manage access to storage.
*/
contract ERC721Registry {
/// @notice Reverts when the registry reaches its configured capacity.
error ERC721RegistryFull();
bytes32 constant STORAGE_POSITION = keccak256("myproject.erc721.registry");
struct ERC721RegistryStorage {
address[] erc721Contracts;
uint256 registryLimit;
}
function getStorage() internal pure returns (ERC721RegistryStorage storage s) {
bytes32 position = STORAGE_POSITION;
assembly {
s.slot := position
}
}
function setRegistryLimit(uint256 _newLimit) internal {
getStorage().registryLimit = _newLimit;
}
function addERC721Contract(address _erc721Contract) internal {
ERC721RegistryStorage storage s = getStorage();
if(s.erc721Contracts.length == s.registryLimit) {
revert ERC721RegistryFull();
}
s.erc721Contracts.push(_erc721Contract);
}
/// @notice Returns a list of all registered ERC721 contract addresses.
/// @return Array of registered ERC721 contract addresses.
function getERC721Registry() internal view returns (address[] memory) {
return getStorage().erc721Contracts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment