r/ethdev • u/greentriangles1 • May 21 '21
Question Help me understand CryptoPunks source code
From what I understand, there were originally 10k punks, each with a unique ID from 1-10000. CryptoPunks was created before ERC-721, so it was an early way to support NFT’s using ERC-20.
What I don’t understand, however, is how the source code has any idea of what the specific token’s image is. The source code includes a
string public imageHash = "ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b";And includes a png of the entire CryptoPunks image set. If you hash this image, you obtain the imageHash above. However, the imageHash isn’t used anywhere in the source code, aside from being defined.
So, if I’m understanding correctly, is the artwork/properties simply being generated on the actual website server-side? As in, they have a list of properties (eg. 'Cap', 'Alien', 'Beard', etc.) associated with every ID that's stored on their website (and not on the blockchain). Then, when you visit their site, it fetches all the ID's on the blockchain, who they're owned by, any bids, etc. and they display that on the Punk's page?
If this is the case, how can it be verified that some of the specific properties of the NFT are true? For instance, if you look on specific Punks, you can see properties like “Alien”. In other words, if the website were to disappear tomorrow, how would those who own the Punks know what accessories each Punk has?
Furthermore, how is OpenSea able to get the image associated with each ID? Or did they manually program this in, since CryptoPunks took off?
7
u/Competitive_Push_52 May 21 '21
Commenting to see the answer. Good question
2
u/jcrestor May 21 '21
Indeed. It addresses one or two issues that I currently have with (some?) NFTs.
1
u/gouhst May 22 '21
What’s the other issue?
1
u/jcrestor May 22 '21
I always asked myself „where“ the actual images of the crypto punks are stored.
Also and more generally I always wonder what it is that you buy with an NFT, and more specifically if it is a thing in and of itself, and what happens if its creator is out of business, or turns malicious.
2
1
1
u/Background-Ad-7863 May 28 '21
I am looking for help. A friend of mine, who is the OG of digital art (started in 1998) wants to launch multiple edition run of his original artwork from 1998. He needs some help with the topic you are discussing. Anyone who wants to help to drop 10.000 NFTs?
1
u/tradedog1 Sep 30 '21
That's actually a brilliant question that very few people must have understood enough to ask it.
1
u/taoqi610 Dec 25 '21
Reading through all the discussion solved my confusion about punks, thanks for the great question.
So if every NFT project chooses their own way to interpret their on-chain "index" to render the NFT, then it seems not scalable for the NFT marketplace like opensea to display these NFTs. I would expect at least some sort of standard to define how to render the art from the onchain data.
1
u/moretti85 Jan 13 '22
The original contract does not include attributes and images.
There's a new contract published from Larva Labs:
https://etherscan.io/address/0x16F5A35647D6F03D5D3da7b35409D65ba03aF3B2#code
0
May 21 '21
[deleted]
8
u/greentriangles1 May 21 '21
Yeah, I figured that's why they included the image in the source code. If anyone wants to verify that the punks on the centralized server are correct, they simply compare it to the one in the source code
What I don't understand, however, is why a hash is needed. Isn't including the image enough? If I buy a Punk at index 10 and compare what I see on their website and the image in the blockchain, it'd be easy to see any visual difference. What utility does the hash actually serve?
If NFT's still require all this centralization to determine what the actual underlying artwork you "own" is, how is it decentralized? The only way I can see to resolve this issue is to algorithmically generate the art within the source code itself, but that may increase the gas fees to insane levels (depending on the complexity of the artwork)
0
May 21 '21
[deleted]
7
u/greentriangles1 May 21 '21
I think it's less that NFTs require this much centralization and more that CryptoPunks chose to implement it this way
This is true, but it seems most NFT collectibles projects are implemented this way. Eg. CryptoKitties (which actually uses ERC-721) has a 256 uint that represents a genetic code that's used for that site's backend to render the artwork of the actual kitten. But if that site were to be removed, I'm not sure if there would be a way for the people who own the kittens to know what they actually look like.
Even worse, CryptoKitties isn't fully decentralized, since the contract owner can literally pause the project at any time, or change the closed-source backend algorithm to increase the rarity of certain cat breeds
What does it say when two of the largest NFT projects have these glaring flaws?
4
u/Treyzania May 21 '21
I'm not sure if there would be a way for the people who own the kittens to know what they actually look like.
You can model the process of generating the image from the "genetic code" as a pure function. In theory there's no reason that the image generation can't be done entirely on the client side, maybe with a large dataset of templates along with it. But that requires the people making the UIs for these things actually care about decentralization.
3
u/greentriangles1 May 21 '21
The uniqueness of a crypto cat is expressed as a single unsigned integer: uint256 genes
The code that reads this meaningless integer and transforms it into a crypto cat with all its good/bad looks, colors, descriptions, etc., is all in a centralized server, closed source, under the control of a central authority.
Unlike a blockchain, where the software is run by every single node, and each upgrade requires a hard or soft fork. The CryptoKitties folks could, at any point, unilaterally change the entirety of how a gene sequence is interpreted — add another tail, change its colour, switch out the description, or turn the cat into a doge.
4
u/Treyzania May 21 '21
is all in a centralized server, closed source, under the control of a central authority.
I'm not saying you could, the developers could. If they wanted to. Which they apparently don't.
3
u/MidnightLightning May 22 '21
Yes, this is all true; NFT technology gives a way to assign "a number" to anything, and it's up to the token's developers to choose how to do that. CryptoPunks and CryptoKitties don't have all the information strictly defined on-chain (punks missing the ordering info and Kitties the imagery). The MoonCatRescue project (/r/MoonCatRescue; a project I loved when it launched and have gotten much more heavily involved with now!) does have all the logic defined on-chain, though part of it is in a rendering script that only the hash is stored on-chain. So you still need to fetch one additional piece to verify it, but from that it's all deterministic.
3
u/greentriangles1 May 22 '21
Yeah, that project you listed seems to be the closest you can get to algorithmically generated art. Aside from directly uploading the artwork on-chain, at least. Perhaps IPFS would be a good middle-ground, if you're trying to create collectibles with more complex art than JS can render
It seems that NFT's require a good deal of trust, that is, the idea that people will value a mere reference to an artwork, rather than actually owning the underlying asset itself (which sort of defeats the purpose of a "trustless" blockchain).
Then again, I never understood the appeal of collecting rare baseball cards and whatnot either
2
1
u/sneakpeekbot May 22 '21
Here's a sneak peek of /r/MoonCatRescue using the top posts of the year!
#1: MoonCat numbers/rarities
#2: MoonCats are on YouTube! Let's spread the story | 9 comments
#3: Hodling that cat - Fresh meme for ya'll | 4 commentsI'm a bot, beep boop | Downvote to remove | Contact ^^me | ^^Info | ^^Opt-out
1
3
u/LiuKangWins May 21 '21
Agreed, there is definitely social construct at play here. In other words, the community of people that value this art all agree that the index references that particular punk in the composite image.
8
u/LiuKangWins May 21 '21
According to the larvalabs website, the hash value embedded in the contract is of the composite image with all 10k punks on it. My understanding of the code is, when a punk is sold the Punk Index is included in the transaction of the sale. The punks appear to be indexed left to right from 1 to 10000. Since the hash included in the contract can only be compared to the exact composite image, then the index therefore must reference the punk that appears on the composite image.