3 ms·
> you write a random string and save it on a blockchain, which becomes the NFT. From there, you can use a lookup table to map the NFT to a URL that links to an
by codetrotter 3y ago
> you write a random string and save it on a blockchain, which becomes the NFT. From there, you can use a lookup table to map the NFT to a URL that links to an image that's stored on the owner's server
The way which they are mapped to images vary from NFT to NFT.
But let's look at Bored Ape Yacht Club specifically.
Collection https://opensea.io/collection/boredapeyachtclub https://opensea.io/collection/boredapeyachtclub
Pick a random bored ape. For example #1337.
https://opensea.io/assets/ethereum/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/1337 https://opensea.io/assets/ethereum/0xbc4ca0eda7647a8ab7c2061...
From there we can see the bored ape Ethereum "smart contract"
https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118...
This contract is responsible for minting all of the original Bored Ape NFTs
Click on "contract". And then click "read contract".
Scroll down. There is a method named "tokenURI". It takes an integer as parameter. Let's query it with value "1337" (the id of the bored ape we are interested in knowing about).
Result:
ipfs://QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/1337
Let's visit that URL via an IPFS gateway.
https://cloudflare-ipfs.com/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/1337 https://cloudflare-ipfs.com/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS...
It contains JSON data.
{"image":"ipfs://QmWjXFUVNjavM4hDzXeQYGXGCXjV86mP7kPEaTeP5bohae","attributes":[{"trait_type":"Background","value":"Yellow"},{"trait_type":"Fur","value":"Dark Brown"},{"trait_type":"Clothes","value":"Bone Necklace"},{"trait_type":"Mouth","value":"Bored Unshaven"},{"trait_type":"Hat","value":"Horns"},{"trait_type":"Eyes","value":"Bloodshot"}]}
We make note of the IPFS URL for the image from here.
ipfs://QmWjXFUVNjavM4hDzXeQYGXGCXjV86mP7kPEaTeP5bohae
And visit that one via our chosen IPFS gateway.
https://cloudflare-ipfs.com/ipfs/QmWjXFUVNjavM4hDzXeQYGXGCXjV86mP7kPEaTeP5bohae https://cloudflare-ipfs.com/ipfs/QmWjXFUVNjavM4hDzXeQYGXGCXj...
So there you have it. Via the Bored Ape smart contract we retrieved the JSON data and image file for Bored Ape #1337 from IPFS.
- ceejayoz 3y ago{"trait_type":"Eyes","value":"Bloodshot"} is a particularly well-chosen example here.
- qingcharles 3y agoRetrieving that image relies on someone continuing to pin the file indefinitely, though, right?
- codetrotter 3y agoThe neat thing about IPFS is that the IPFS URL is based on a hash of the file. So having saved that file offline on my harddrive, I can later re-add it to IPFS. ipfs add Downloads/1337.png added QmWjXFUVNjavM4hDzXeQYGXGCXjV86mP7kPEaTeP5bohae 1337.png 140.68 KiB / 140.68 KiB [=============================================] 100.00% Notice that because I added the same file to my local ipfs, it got the same id as it had when I retrieved it. QmWjXFUVNjavM4hDzXeQYGXGCXjV86mP7kPEaTeP5bohae So, IPFS doesn't even require that the file is indefinitely pinned. And if I have a public node, others can now once again retrieve the file using the same known id. The person that re-adds it doesn't have to (nor can) specify the id of the file; that's calculated from the hash of it. (Although, IPFS does also have a way to serve mutable data, so in those cases the id is not calculated directly from just a hash. But in the case of the image we looked at here we see that it was.) The difference between needing to pin forever and merely needing to have a copy of the same file somewhere outside of IPFS which is then re-added to IPFS and gets the same ID is a fine distinction perhaps, but still an important one IMO. And I think that even if all of the IPFS nodes that currently have a copy of the Bored Apes would go offline, there is probably someone out there who would notice that and for whatever reason be motivated to make all of the apes available again on IPFS with their same original id's that they had by re-adding the original files.
- qingcharles 3y agoRight, it's like a torrent in that way. I have dozens of torrents where I am waiting for that one guy to -- bless his soul -- open up his torrent client and seed the last 14 bytes. I guess the best thing to do if you own an Ape is to store the image on your HDD and put a copy in a safe-deposit box, and then pin it yourself whenever you can.
- LelouBil 3y agoThanks for the explanation, it makes a bit more sense that it is an ipfs URL.
- codetrotter 3y agoAs mentioned though, it varies between different NFT projects. Some NFT projects lazily use Google Drive links etc instead. And then the files in the Google Drive could later be modified or deleted. See for example https://web3isgoinggreat.com/?tech=nft&id=goblintown-nft-images-all-changed-to-an-illustrated-middle-finger-in-protest-about-royalties https://web3isgoinggreat.com/?tech=nft&id=goblintown-nft-ima... > Goblintown NFT images all changed to an illustrated middle finger in protest about royalties