{"id":"nft-standards","name":"nft-standards","summary":"適切なメタデータ処理、ミンティング戦略、マーケットプレイス統合を用いてNFT標準(ERC-721、ERC-1155)を実装しましょう。","body":"# NFT Standards\n\nMaster ERC-721 and ERC-1155 NFT standards, metadata best practices, and advanced NFT features.\n\n## When to Use This Skill\n\n- Creating NFT collections (art, gaming, collectibles)\n- Implementing marketplace functionality\n- Building on-chain or off-chain metadata\n- Creating soulbound tokens (non-transferable)\n- Implementing royalties and revenue sharing\n- Developing dynamic/evolving NFTs\n\n## ERC-721 (Non-Fungible Token Standard)\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/Counters.sol\";\n\ncontract MyNFT is ERC721URIStorage, ERC721Enumerable, Ownable {\n    using Counters for Counters.Counter;\n    Counters.Counter private _tokenIds;\n\n    uint256 public constant MAX_SUPPLY = 10000;\n    uint256 public constant MINT_PRICE = 0.08 ether;\n    uint256 public constant MAX_PER_MINT = 20;\n\n    constructor() ERC721(\"MyNFT\", \"MNFT\") {}\n\n    function mint(uint256 quantity) external payable {\n        require(quantity > 0 && quantity <= MAX_PER_MINT, \"Invalid quantity\");\n        require(_tokenIds.current() + quantity <= MAX_SUPPLY, \"Exceeds max supply\");\n        require(msg.value >= MINT_PRICE * quantity, \"Insufficient payment\");\n\n        for (uint256 i = 0; i < quantity; i++) {\n            _tokenIds.increment();\n            uint256 newTokenId = _tokenIds.current();\n            _safeMint(msg.sender, newTokenId);\n            _setTokenURI(newTokenId, generateTokenURI(newTokenId));\n        }\n    }\n\n    function generateTokenURI(uint256 tokenId) internal pure returns (string memory) {\n        // Return IPFS URI or on-chain metadata\n        return string(abi.encodePacked(\"ipfs://QmHash/\", Strings.toString(tokenId), \".json\"));\n    }\n\n    // Required overrides\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId,\n        uint256 batchSize\n    ) internal override(ERC721, ERC721Enumerable) {\n        super._beforeTokenTransfer(from, to, tokenId, batchSize);\n    }\n\n    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {\n        super._burn(tokenId);\n    }\n\n    function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) {\n        return super.tokenURI(tokenId);\n    }\n\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        override(ERC721, ERC721Enumerable)\n        returns (bool)\n    {\n        return super.supportsInterface(interfaceId);\n    }\n\n    function withdraw() external onlyOwner {\n        payable(owner()).transfer(address(this).balance);\n    }\n}\n```\n\n## ERC-1155 (Multi-Token Standard)\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC1155/ERC1155.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract GameItems is ERC1155, Ownable {\n    uint256 public constant SWORD = 1;\n    uint256 public constant SHIELD = 2;\n    uint256 public constant POTION = 3;\n\n    mapping(uint256 => uint256) public tokenSupply;\n    mapping(uint256 => uint256) public maxSupply;\n\n    constructor() ERC1155(\"ipfs://QmBaseHash/{id}.json\") {\n        maxSupply[SWORD] = 1000;\n        maxSupply[SHIELD] = 500;\n        maxSupply[POTION] = 10000;\n    }\n\n    function mint(\n        address to,\n        uint256 id,\n        uint256 amount\n    ) external onlyOwner {\n        require(tokenSupply[id] + amount <= maxSupply[id], \"Exceeds max supply\");\n\n        _mint(to, id, amount, \"\");\n        tokenSupply[id] += amount;\n    }\n\n    function mintBatch(\n        address to,\n        uint256[] memory ids,\n        uint256[] memory amounts\n    ) external onlyOwner {\n        for (uint256 i = 0; i < ids.length; i++) {\n            require(tokenSupply[ids[i]] + amounts[i] <= maxSupply[ids[i]], \"Exceeds max supply\");\n            tokenSupply[ids[i]] += amounts[i];\n        }\n\n        _mintBatch(to, ids, amounts, \"\");\n    }\n\n    function burn(\n        address from,\n        uint256 id,\n        uint256 amount\n    ) external {\n        require(from == msg.sender || isApprovedForAll(from, msg.sender), \"Not authorized\");\n        _burn(from, id, amount);\n        tokenSupply[id] -= amount;\n    }\n}\n```\n\n## Metadata Standards\n\n### Off-Chain Metadata (IPFS)\n\n```json\n{\n  \"name\": \"NFT #1\",\n  \"description\": \"Description of the NFT\",\n  \"image\": \"ipfs://QmImageHash\",\n  \"attributes\": [\n    {\n      \"trait_type\": \"Background\",\n      \"value\": \"Blue\"\n    },\n    {\n      \"trait_type\": \"Rarity\",\n      \"value\": \"Legendary\"\n    },\n    {\n      \"trait_type\": \"Power\",\n      \"value\": 95,\n      \"display_type\": \"number\",\n      \"max_value\": 100\n    }\n  ]\n}\n```\n\n### On-Chain Metadata\n\n```solidity\ncontract OnChainNFT is ERC721 {\n    struct Traits {\n        uint8 background;\n        uint8 body;\n        uint8 head;\n        uint8 rarity;\n    }\n\n    mapping(uint256 => Traits) public tokenTraits;\n\n    function tokenURI(uint256 tokenId) public view override returns (string memory) {\n        Traits memory traits = tokenTraits[tokenId];\n\n        string memory json = Base64.encode(\n            bytes(\n                string(\n                    abi.encodePacked(\n                        '{\"name\": \"NFT #', Strings.toString(tokenId), '\",',\n                        '\"description\": \"On-chain NFT\",',\n                        '\"image\": \"data:image/svg+xml;base64,', generateSVG(traits), '\",',\n                        '\"attributes\": [',\n                        '{\"trait_type\": \"Background\", \"value\": \"', Strings.toString(traits.background), '\"},',\n                        '{\"trait_type\": \"Rarity\", \"value\": \"', getRarityName(traits.rarity), '\"}',\n                        ']}'\n                    )\n                )\n            )\n        );\n\n        return string(abi.encodePacked(\"data:application/json;base64,\", json));\n    }\n\n    function generateSVG(Traits memory traits) internal pure returns (string memory) {\n        // Generate SVG based on traits\n        return \"...\";\n    }\n}\n```\n\n## Royalties (EIP-2981)\n\n```solidity\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\n\ncontract NFTWithRoyalties is ERC721, IERC2981 {\n    address public royaltyRecipient;\n    uint96 public royaltyFee = 500; // 5%\n\n    constructor() ERC721(\"Royalty NFT\", \"RNFT\") {\n        royaltyRecipient = msg.sender;\n    }\n\n    function royaltyInfo(uint256 tokenId, uint256 salePrice)\n        external\n        view\n        override\n        returns (address receiver, uint256 royaltyAmount)\n    {\n        return (royaltyRecipient, (salePrice * royaltyFee) / 10000);\n    }\n\n    function setRoyalty(address recipient, uint96 fee) external onlyOwner {\n        require(fee <= 1000, \"Royalty fee too high\"); // Max 10%\n        royaltyRecipient = recipient;\n        royaltyFee = fee;\n    }\n\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        override(ERC721, IERC165)\n        returns (bool)\n    {\n        return interfaceId == type(IERC2981).interfaceId ||\n               super.supportsInterface(interfaceId);\n    }\n}\n```\n\n## Additional patterns and templates\n\nMore detailed templates and worked examples live in `references/details.md`. Read that file for the full pattern library.","author":"@wshobson","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/wshobson/agents/tree/main/plugins/blockchain-web3/skills/nft-standards","license":"MIT","category":"coding","lang":"en","tokens":1712,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/details.md","size":2582,"sha256":"ff9f6e8e334c895430793dd3dfe8d64091cb029fdcf50d1d24e32196404e366c"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}