Developer-DAO / pixel-avatars

A Polygon-based minting projects for Developer DAO members who own an Devs for Revolution NFT

Home Page:https://pixel-devs.developerdao.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Smart Contract Brainstorm

etherinsight opened this issue · comments

Here's my thoughts on how to deploy smart contract for the pixel avatars. Basically we want to create a way for existing DevDao token holders to claim a token on pixel avatar contract. All the image metadata can be added at mint time or after mint.
A good discussion about this topic can be found here:
Openzepplin discussion forum

Stack exchange


Let's look at other projects that have implement this kind of requirement. Which is If msg.sender is a token holder in original contract , let them mint a token form the new contract.

Gan Apes is a project that is mintable by Bloot token holders( bloot is similar to loot and launched by making small changes to the Loot contract, similar to Developer dao project. )

Opensea for Gan Apes: https://opensea.io/collection/gan-apes-nft
Etherscan for Gan Apes: https://etherscan.io/address/0xbae6f981dc151cfc633212f06a9c5b4e37920454#code

Gan Ape images are stored in IPFS and this metadata location can be queried by reading the contract's tokenURI method
image

image

This is the metadata for token 1003 when I view the IPFS string returned from the step avobe
https://bafybeicnsgu6unnctx4hczjv7jgo6cohqckh33kcy4l5bnsxtyzak6btoy.ipfs.dweb.link/1003

{
    "name": "GAPE #1003",
    "image": "ipfs://QmcLrdSvoiTtFhABitH59NoSBRsFAUbibVLjCydspcZj8T/1003.jpg"
}

This metadata has a image location on ipfs and when I navigate to that image uri ( via a browser like Brave which supports ipfs) I get the image. That image is used by Opensea and other NFT platforms.


So testing plan for our project can be something like:

  1. find the testnet version of developer dao contract.

  2. Create a Dummy metadata file for a few tokens based on this tutorial. Basically we can create a metadata server by a file hosted on github repo:

  1. Deploy another contract based on the GAN Ape contract above and allow list the DevDao Rinkeby contract so only Dev Dao token holders on Riknkeby can mint pixel tokens. Set the tokenURI to the uri we create in step 2.

Thoughts?

I ended up using LootTunes contract as a reference contract to let DevDao token holders mint the pixel avatars on testnet.

LootTunes is a derivative of Loot Project where holders can use their token id to mint a LootTune. I picked this example because this derivative has metadata stored on ipfs unlike many other loot derivatives which have all the metadata on-chain.

LootTunes contract: https://rinkeby.etherscan.io/address/0x2fe239cf742f02b4622b0fba7adf4f14be9f7187#code

--
I used Remix Ide to deploy Pixel Avatart code to Rinkeby. Remix Ide is web based and provided by Ehtereum foundation for free. https://remix.ethereum.org/

Deployed Pixel Avatar Contract: https://rinkeby.etherscan.io/address/0x2fe239cf742f02b4622b0fba7adf4f14be9f7187#code

I copied the LootTunes code to Remix IDE and changed the following things:

import json
data=[]
for i in range(1,1001):
    item = {"id": i, "image":"https://raw.githubusercontent.com/Developer-DAO/pixel-avatars/main/assets/backgrounds/blue.png", "name": "Pixel Avatar #"+str(i) }

    data.append(item)

jsonData=json.dumps(data)

print(jsonData)
  • After getting the code ready. I flattened the contract file using a Flattener plugin on remix and deployed the contract.
  • Then I verified the contract on etherscan.
  • I minted/claimed token id 99 from the Avatar contract since I had token id 99 under Dev Dao testnet contract

After a few minutes of minting token id 99 Opensea showed the NFT.

image