sCrypt-Inc / scrypt-ord

sCrypt 1sat ordinal library
https://docs.scrypt.io/tokens/
19 stars 5 forks source link

Problem with content file format returned by OrdinalNFT.getInscription() when inscription is PNG image #38

Closed anthonymonaco1 closed 11 months ago

anthonymonaco1 commented 11 months ago

Hi, I am having trouble with the getInscription function from the OrdinalNFT contract class. I have inscribed a PNG image using the following code:

const imageData = fs.readFileSync('test.png').toString('base64') const mintTx = await instance.inscribeImage(imageData, 'image/png') const inscription = instance.getInscription().content fs.writeFileSync('inscription.png', inscription)

I want to be able to check the image inscription that is stored on chain to see that it is actually the correct image. However, the result of console.log(inscription) is an unrecognised string format, here is a chunk of the inscription returned from an example png:

�PNG

IHDR��X��gAMA�� �a cHRMz&�����u0�`:�p��Q<�eXIfMMJ(�iZHH��Ƞ�haP� pHYs

                                                                ��YiTXtXML:com.adobe.xmp<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0">
1 ^�$�IDATx�]{�\E���{�g&�!�h�y%�����]�< �Gpu�=��c]9G]�L�C:�BP�앇�^팛N/��,�$�C�X���e�̌�~! ��ت�F�����l�ƶq!:��� ��K�Og��I��8ЧMH9GHGI�p9���)��Жe��曗���Q��"<����!���B�;�/vx��߽�������ٱu^��H�d(SN�@ h�Y�ڰ�@]�8F]�ޑ�����_i�FNQ�N �NC�~~_P�W��@��/�:�}�A���%-���1�DDLbh$�T �7}��Cꀖ���k����rs۶��v�K86%������g�2��}$�9� ��Ӓ�z9�]HӢ/f��w��I1���y�Lԑ�O�F�y�8FLq cK8==B��.%ڗm|��ę�gc�? i@Y$���T�g��qbj��6g��m�2�&�z2���GuͰd p)�3A$�i���^2!)HJ�����+�.�� ��T��\�u�: :��)�,A,�B���f�?���|9y�1"��� �*�5G�݉�=j��I���;ג�fR:}qS6KjX�����{g��N��� I have also tried converting the inscription to a buffer object and then using `fs.writeFileSync()` with the buffer, which has also not worked. `getInscription()` worked perfectly when I tried to retrieve a text inscription made using `inscribeText()`.