diff --git a/src/standard/TIP-4/2.md b/src/standard/TIP-4/2_1.md similarity index 97% rename from src/standard/TIP-4/2.md rename to src/standard/TIP-4/2_1.md index 4e50af415..9cd7e0390 100644 --- a/src/standard/TIP-4/2.md +++ b/src/standard/TIP-4/2_1.md @@ -1,10 +1,10 @@ --- -title: 4.2. JSON Metadata +title: 4.2. On-chain JSON Metadata sidebar_position: 2 -slug: /standard/TIP-4.2 +slug: /standard/TIP-4.2.1 --- -# Non-Fungible Token JSON Metadata (TIP-4.2) +# Non-Fungible Token on-chain JSON Metadata (TIP-4.2.1) Requires: [TIP-6.1](./../TIP-6/1.md) @@ -26,7 +26,7 @@ The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL N Return the metadata as JSON -Every TIP4.2 compliant contract must implement the `TIP4_2JSON_Metadata` interface and [TIP-6.1](./../TIP-6/1.md) interfaces +Every TIP4.2.1 compliant contract must implement the `TIP4_2JSON_Metadata` interface and [TIP-6.1](./../TIP-6/1.md) interfaces ```solidity pragma ton-solidity >= 0.58.0; @@ -326,7 +326,7 @@ Sphere is described by coordinates of central point and radius. ## How to add the new JSON metadata type? -For added new metadata type of [TIP-4.2](2.md) +For added new metadata type of [TIP-4.2.1](2_1.md) - Create product that use new JSON type. - Send PR for change the docs. diff --git a/src/standard/TIP-4/2_2.md b/src/standard/TIP-4/2_2.md new file mode 100644 index 000000000..be5d80d64 --- /dev/null +++ b/src/standard/TIP-4/2_2.md @@ -0,0 +1,183 @@ +--- +title: 4.2.2 New JSON Metadata +sidebar_position: 2 +slug: /standard/TIP-4.2.2 +--- +# Non-Fungible Token JSON Metadata (TIP-4.2.2) +``` +author: ELena Khramtsova , Aleksandr Khramtsov +type: Contract +created: 2024-06-07 +Requires: TIP-6 +``` +## Abstract + +This is an alternative standard for storing metadata, but in a more familiar form for EVM users of such networks. It is not compatible with basic Tip4.2 + +This standard proposes storing metadata outside the blockchain (centralized backing, ipfs, etc.) + +## Motivation + +The implementation below solves several problems at once: +- For Mystery-type collections, it makes reveal cheap and makes it easier to execute +- Helps avoid storing json onchain. Storing and replacing json in a contract is expensive. +- Makes it possible to change metadata without making a bunch of transactions to the blockchain +- Familiar metadata format for those who have already released collections on EVM +- In the future, this will make it easier to bridge/issue nft on multiple blockchains + +## Specification + +The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119) + +## TIP4_2_2Collection + +New features appear in the collection. + +```solidity +pragma ever-solidity >= 0.62.0; + +interface ITIP4_2_2Collection { + + /// The TIP-6.1 identifier for this interface is 0x244a5200 + + /// @notice The event emits when set or change collection metadata + event CollectionMetadataUpdated(); + + /// @notice The event emits when set or change NFTs metadata + event NftMetadataUpdated(); + + /// @notice build url to get metadata for NFT + /// @return nftUrl - url to get metadata for NFT + /// @param parts is TvmCell from NFT for build the link to metadata + function getNftUrl(TvmCell parts) external responsible returns (string nftUrl); + + /// @notice build url to get metadata for NFT + /// @return collectionUrl - url to get metadata for NFT + function getCollectionUrl() external view responsible returns (string collectionUrl); + +} +``` +**NOTE** The [TIP-6.1](./../TIP-6/1.md) identifier for this interface is `0x244a5200`. + +### TIP4_2_2Collection.getNftUrl() +```solidity +function getNftUrl(TvmCell parts) external responsible returns (string nftUrl); +``` +* `parts` (`TvmCell`) - is TvmCell from NFT for build the link to metadata + +The function, based on the main link and the part it received, builds the final link to the NFT metadata. In the case of collections, mystery box can describe more complex logic in which the display of the final link will depend on the flag the sale of the collection is completed or not. + +### TIP4_2_2Collection.getCollectionUrl() +```solidity +function getCollectionUrl() external view responsible returns (string collectionUrl); +``` +The function is analogous to the getJson function in the Type4.2 standard but returns not json but a link to the json metadata of the collection. + +```solidity +event CollectionMetadataUpdated(); +event NftMetadataUpdated(); +``` +You must emit them when you change the metadata of collection or NFT. + +## TIP4_2_2NFT + +Each NFT now stores only a part of the link by which the metadata for it can be uniquely identified, and the metadata can be obtained by attaching this part to the collection function `getNftUrl(TvmCell parts)`. + +**NOTE** The [TIP-6.1](./../TIP-6/1.md) identifier for this interface is `0x7239d7b1`. +```solidity +pragma ever-solidity >= 0.62.0; + +interface ITIP4_2_2NFT { + + + /// The TIP-6.1 identifier for this interface is 0x7239d7b1. + + /// @notice event emits when update NFT part. + event MetadataUpdated(); + + /// @notice NFT part to get metadata + /// @return part - TvmCell allows to build URL with metadata for this NFT + function getUrlParts() external view responsible returns (TvmCell part); + +} +``` + +### ITIP4_2_2NFT.getUrlParts() +```solidity +function getUrlParts() external view responsible returns (TvmCell part); +``` +The function returns the part identifying the NFT in the form of a TvmCell, which gives greater variability. In the simplest version, this could be id. + +You must emit event `MetadataUpdated()` when NFT part update. + +### Metadata format +JSON metadata type: "Basic NFT" + +The `Basic NFT` use for links to files stores in web. JSON fields contain information about item, files and preview info. + +The `Basic NFT` describes fields that must be in JSON. +The `attributes` field may not be present in the JSON metadata. + +| Field name | type | Value | Description | +|----------------------|--------|----------------------------------------------------------------------------------------------------|-----------------------------| +| **type** | string | "Basic NFT" | Constant name for this type | +| **name** | string || Name of the object | | +| **description** | string || Description of the object | | +| **preview** | object || Object preview | | +| **preview.source** | string || Link to object. Contains protocol and data source. Delimiter is **:** | | +| **preview.mimetype** | string || [Mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of object | | +| **files** | array || Array of objects. | | +| **file.source** | string || Link to object. Contains protocol and data source. Delimiter is **:** | | +| **file.mimetype** | string || [Mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of object | | +| **attributes** | array || Array of objects. | | +| **attributes.trait_type** | string || Type of attribute (Base, Eyes ...) | | +| **attributes.value** | string || Value of attribute (Starfish, Blue ...) | | +| **external_url** | string || URL to website | | + +### Example + +```JSON +{ + "type": "Basic NFT", + "name": "Sample Name", + "description": "Hello world!", + "preview": { + "source": "https://everscale.network/images/Backgrounds/Main/main-hero.png", + "mimetype": "image/png" + }, + "files": [ + { + "source": "https://everscale.network/images/Backgrounds/Main/main-hero.png", + "mimetype": "image/png" + } + ], + "attributes": [ + { + "trait_type": "Base", + "value": "Starfish" + }, + { + "trait_type": "Eyes", + "value": "blue" + } ] + "external_url": "https://everscale.network" +} +``` + +You can extend `Basic NFT` type for your custom fields. + +## How to add the new JSON metadata type? + +For added new metadata type of [TIP-4.2](2.md) + +- Create product that use new JSON type. +- Send PR for change the docs. +- Explain why it will be in Standard. + +## References + +- [Ethereum EIP-721](https://eips.ethereum.org/EIPS/eip-721) +- [Solana v1.2.0](https://docs.metaplex.com/token-metadata/specification) +- [TON NFT](https://github.com/ton-blockchain/TIPs/issues/62), [TON DATA](https://github.com/ton-blockchain/TIPs/issues/64) +- [Tezos TZIP12](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-12/tzip-12.md) +- [BNS BEP721](https://docs.binance.org/smart-chain/developer/nft-metadata-standard.html)