Shared Storage Architecture

Facets and Libraries Working Together

Both facets and libraries access the same storage in your diamond. Your custom facets can extend Compose functionality without inheritance.

Facets

Complete, reusable implementations

Libraries

Helper functions for custom facets

Shared Storage

Both work with the same data

Learn More
GameNFTFacet.sol
// Your custom facet uses LibERC721
import {LibERC721} from "compose/LibERC721.sol";

contract GameNFTFacet {
    function mintWithGameLogic(
        address player,
        uint256 tokenId
    ) external {
        // Your custom game logic
        require(
            playerHasEnoughPoints(player),
            "Not enough points"
        );

        // Use LibERC721 - same storage!
        LibERC721.mint(player, tokenId);

        // Standard ERC721Facet functions
        // work seamlessly
        updatePlayerStats(player);
    }
}