@@ -101,13 +101,25 @@ contract ERC721EthscriptionsCollection is ERC721EthscriptionsEnumerableUpgradeab
101101 manager.getCollectionItem (collectionId, tokenId);
102102 if (item.ethscriptionId == bytes32 (0 )) revert ("Token not in collection " );
103103
104+ // Get the ethscription data to extract the ethscription number
105+ Ethscriptions.Ethscription memory ethscription = ethscriptions.getEthscription (item.ethscriptionId, false );
106+
104107 (string memory mediaType , string memory mediaUri ) = ethscriptions.getMediaUri (item.ethscriptionId);
105108
109+ // Convert ethscriptionId to hex string (0x prefixed)
110+ string memory ethscriptionIdHex = uint256 (item.ethscriptionId).toHexString (32 );
111+
106112 string memory jsonStart = string .concat ('{"name":" ' , item.name.escapeJSON (), '" ' );
107113 if (bytes (item.description).length > 0 ) {
108114 jsonStart = string .concat (jsonStart, ',"description":" ' , item.description.escapeJSON (), '" ' );
109115 }
110116
117+ // Add ethscription ID and number
118+ string memory ethscriptionFields = string .concat (
119+ ',"ethscription_id":" ' , ethscriptionIdHex, '" ' ,
120+ ',"ethscription_number": ' , ethscription.ethscriptionNumber.toString ()
121+ );
122+
111123 string memory mediaField = string .concat (
112124 '," ' ,
113125 mediaType,
@@ -135,7 +147,7 @@ contract ERC721EthscriptionsCollection is ERC721EthscriptionsEnumerableUpgradeab
135147 }
136148 attributesJson = string .concat (attributesJson, '] ' );
137149
138- string memory json = string .concat (jsonStart, mediaField, bgColor, attributesJson, '} ' );
150+ string memory json = string .concat (jsonStart, ethscriptionFields, mediaField, bgColor, attributesJson, '} ' );
139151
140152 return string .concat ("data:application/json;base64, " , Base64.encode (bytes (json)));
141153 }
0 commit comments