stacks-blockchain-api icon indicating copy to clipboard operation
stacks-blockchain-api copied to clipboard

Complete NFT `class` metadata support

Open zone117x opened this issue 4 years ago • 2 comments

Originally posted by @zone117x in https://github.com/blockstack/stacks-blockchain-api/issues/576#issuecomment-898695717

Processing token metadata works pretty well for SIP-010 compliant FTs. Here's an example from Citycoins on testnet: http://localhost:3999/extended/v1/tokens/ST3CK642B6119EVC6CT550PW5EZZ1AJW6608HK60A.citycoin-token/ft/metadata

{
"token_uri": "https://cdn.citycoins.co/metadata/citycoin.json",
"name": "citycoins",
"description": "The CityCoin template used for testing, mine and stack to support your favorite city while earning STX yield!",
"image_uri": "https://stacks-api.imgix.net/https%3A%2F%2Fcdn.citycoins.co%2Flogos%2Fcitycoin.png?s=b30bf0315b374c32e4d9e953c46bb759",
"image_canonical_uri": "https://cdn.citycoins.co/logos/citycoin.png",
"symbol": "CYCN",
"decimals": 0,
"tx_id": "0x6c2c95a2404199a2ff0e8372d39cdf1be06f5ce1173b680a56dfdf27467ab6b2",
"sender_address": "ST3CK642B6119EVC6CT550PW5EZZ1AJW6608HK60A"
}

NFTs aren't working so well -- the code needs updated to use draft SIP-012 which defines NFT class metadata. Draft SIP-012 is still WIP, and after looking through various NFT contracts on mainnet, it looks like there's a few different ways authors have been defining metadata, examples:

https://explorer.stacks.co/txid/0x3f85e8d2a5453179438ed00e466e38b6c4acb3d2cefa579d20389b84602a12e7?chain=mainnet
(define-read-only (get-nft-meta)
  (ok {name: "Friedger Pool", uri: "https://pool.friedger.de/nft.png", mime-type: "image/png"}))
(define-read-only (get-token-uri (token-id uint))
  (ok (some "https://pool.friedger.de/nft.json")))

https://explorer.stacks.co/txid/0x7246cfb663ddd90041781919961a131938d34345879d708ed7d855039c70b84d?chain=mainnet
(define-read-only (get-nft-meta)
  (ok (some {name: "Clarity Developer OG", uri: "https://bafybeif4p2ukltj5eofwriclz4ru3p7izitprrs7a2rjhtp6qat673wagu.ipfs.dweb.link/", mime-type: "video/webm"})))

https://explorer.stacks.co/txid/0x5d1704291538dbeb201161f9f052f79281bea2a944f8c22e4ebdf67005d2b429?chain=mainnet
(define-read-only (get-nft-meta)
  (ok {name: "First Ever Hiro Hackathon Winner", uri: "https://ipfs.io/ipfs/QmXTeyFsiCGsB6st5FTbvc78RkXG8hKo5SxtCN8cv8ity3/hiro-first-hackathon.webm", mime-type: "video/webm",
        hash: "e4ce55dd89113b846c4d43f7018f66e57e7b12d6af960e2a143f91457d27e1f0"}))

https://explorer.stacks.co/txid/0xe865963227144aec75259f9c1f8e67b2d2b5764a29ba88a5794a700818659748?chain=mainnet
(define-read-only (get-nft-meta)
  {uri: "https://boom-nft-41369b66-36da-4442-be60-fff6d755b065.s3.amazonaws.com/24762181-0ba6-4c5b-9065-1c874fb334d2.svg", name: "Boomboxes", mime-type: "image/svg+xml"})

https://explorer.stacks.co/txid/0x10555a156fbd5931f2b33e843221ce73e3fd661127c64d840c3f8392dbd6887c?chain=mainnet
(define-read-only (get-nft-meta)
  (ok {name: "Friedger Pool", uri: "https://pool.friedger.de/nft.webp", mime-type: "image/webp"}))

https://explorer.stacks.co/txid/0x8f0393265a8a4102701ef6240b03022c567cf67f04e472e077709fe975424921?chain=mainnet
(define-read-only (get-nft-meta)
  (ok (some {name: "beeple", uri: "https://ipfsgateway.makersplace.com/ipfs/QmZ15eQX8FPjfrtdX3QYbrhZxJpbLpvDpsgb2p3VEH8Bqq", mime-type: "image/jpeg"})))
(define-read-only (get-token-uri (token-id uint))
  (ok (some "ipfs://ipfs/QmPAg1mjxcEQPPtqsLoEcauVedaeMH81WXDPvPx3VC5zUz")))

https://explorer.stacks.co/txid/0x8a8b1bd754664715c3280cb41fdf566c741789f200efa74681b79e4409e9800a?chain=mainnet
(define-read-only (get-nft-meta)
  (ok (some {name: "beeple", uri: "https://ipfsgateway.makersplace.com/ipfs/QmZ15eQX8FPjfrtdX3QYbrhZxJpbLpvDpsgb2p3VEH8Bqq", mime-type: "image/jpeg"})))


https://explorer.stacks.co/txid/0x5d8f968111be4556a13d8d0d25f39d998a749a982d673ae6ba7180ee7ccf1f62?chain=mainnet
(define-read-only (get-token-uri (id uint))
  (ok (some "https://cloudflare-ipfs.com/ipfs/bafkreidmfmsjiqunj4tkln57ozw2yhazufqv63j5zohhsqchwol6lznsfy")))

The NFT metadata processing code needs updated to handle the 2 or 3 common ways metadata is defined.

zone117x avatar Sep 07 '21 12:09 zone117x

I am having trouble with local stacks api.

"error": "FT metadata processing is not enabled on this server"

I have the flag to allow it set to 1. What gives? I am currently synching and at block height 1854

unclemantis avatar Dec 02 '21 13:12 unclemantis

This issue is related to NFT class metadata, the error FT metadata processing is not enabled on this server is for FT class metadata.

zone117x avatar Dec 07 '21 10:12 zone117x

Replaced by #1222

rafaelcr avatar Aug 29 '22 14:08 rafaelcr