News for hackers. Stuff that matters.
Re:Bored Ape conference attendees wake up with eye pain, vis... by codetrotter on Monday November 06, 2023 @08:55PM (#38172175)
> 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

Pick a random bored ape. For example #1337.

https://opensea.io/assets/ethereum/0xbc4ca0eda7647a8ab7c2061...

From there we can see the bored ape Ethereum "smart contract"

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/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/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.

Re:Bored Ape conference attendees wake up with eye pain, vis... by qingcharles on Monday November 06, 2023 @09:38PM (#38172507)
Retrieving that image relies on someone continuing to pin the file indefinitely, though, right?
Re:Bored Ape conference attendees wake up with eye pain, vis... by codetrotter on Monday November 06, 2023 @09:50PM (#38172584)
The 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.

Re:Bored Ape conference attendees wake up with eye pain, vis... by qingcharles on Tuesday November 07, 2023 @12:13AM (#38173526)
Right, 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.

Re:Bored Ape conference attendees wake up with eye pain, vis... by ceejayoz on Monday November 06, 2023 @09:18PM (#38172355)
{"trait_type":"Eyes","value":"Bloodshot"} is a particularly well-chosen example here.
Re:Bored Ape conference attendees wake up with eye pain, vis... by LelouBil on Tuesday November 07, 2023 @03:20AM (#38174440)
Thanks for the explanation, it makes a bit more sense that it is an ipfs URL.
Re:Bored Ape conference attendees wake up with eye pain, vis... by codetrotter on Tuesday November 07, 2023 @08:49AM (#38176649)
As 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-ima...

> Goblintown NFT images all changed to an illustrated middle finger in protest about royalties