Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get image data into nft data

Tags:

nft

scrypto

Assume I have a .jpg or .png file, I want to integrate this image data into a NonFungibleData in Scrypto, how can I do it? Should I use Decimal? HashMap?

like image 818
PeterKim Avatar asked Nov 02 '25 13:11

PeterKim


1 Answers

Normally, you wouldn't store the image inside the NFT metadata (it would cost too much).

What you could instead do is host the image using IPFS and store its link along with the hash of the image in the metadata of the NFT.

Here is an example:

#[derive(NonFungibleData)]
struct BoredGumballClub {
    ipfs_link: String,
    image_hash: Hash,
    hat: Hat,
    eyes: Eyes,
    mouth: Mouth,
    shirt: Shirt
}

At the moment, there are no standards around the name of the fields you should have on the NFT metadata to be able to display them correctly on explorers and wallets. Standards should emerge the closer we get to Babylon.

like image 189
Clement Avatar answered Nov 04 '25 19:11

Clement