Please check my code here => https://github.com/ZexCraft
Description
ZexCraft is a NFT minting/breeding platform where users can form relationships between NFTs and grow their legacy and visualise it in a family tree. Users can unleash their creativity by creating NFTs with an AI prompt. NFT owners can form relationships using their NFTs with other NFTs owned by other users. By forming relationships users can create hybrid family trees like BAYC/PUNK, Azuki/ZEX etc. NFTs when they breed with each other form new NFTs that look like a combination of both NFT using AI. Every AI generated NFT has rarity that determines its value. There are 6 levels of rarity: Common, Basic, Rare, Epic, Legendary, ZexStar. Rarity is generated on-chain and this rarity determines the colour theme of the NFT. Users can purchase power-ups to boost their NFTs and their breeding abilities. From the user perspective, these Zexcrafted NFTs create new communities and new possibilities to form CrossNFTCollection relationships across different blockchains. NFT collections in any blockchain will be able to form relationships, create new offsprings and grow their family line.
User story
User enters the app and can view other AI generated NFTs and imported NFTs from different blockchains in the home page. User can also view relationships and family trees.
If the user does not own any NFT, he can choose to create a new one with an AI prompt. He goes to the create page, chooses the chain in which he needs to pay the mint fee to generate the NFT. For this hackathon, the user pays with Native currency for Avalanche and with CCIP-BnM as the mint fee for any chain other than Avalanche. In future, other currencies and Non-EVM blockchains will be supported. On paying the mint fee, the user provides a prompt that triggers the smart contract to generate a new NFT. The smart contract produces rarity and creates the new NFT on-chain. After successfully creating a new NFT, the user makes an another call to create an NFT-owned account for the new ZexCrafted NFT.
If the user already owns an NFT, the user can go to his profile and import his NFT by entering the contract address and token id. The user can import any NFT on the supported blockchains. This transaction creates an NFT-owned account for his NFT in this application.
After creating the NFT owned account for the NFT, the user can choose to form relationships with any NFT that is created/imported/bred in ZexCraft. The user needs the signature of the other NFT holder to form the relationship. By forming the relationship, the pair gets added to an existing family tree if compatible (BAYC/PUNK family tree only accepts a BAYC or PUNK partner) or can choose to create a new family tree. The user will be able to view the interactive family tree in the application.
The pair can opt to breed and create a new NFT. This generates a new NFT using AI which will be the blend of both the parent NFTs. This NFT has its own rarity which is generated in the smart contract. After successfully creating a new NFT, the pair makes an another call to create an NFT-owned account for the new ZexCrafted NFT.
The user can go to Power-ups section to purchase power-ups using any supported currency. Using these power-ups, users can breed better ZexCraftNFTs.
Technical implementation
Chainlink
5 Chainlink Services are used in ZexCraft.
- Chainlink Functions - To create NFTs.
- Chainlink CCIP - To form cross-chain relationships. To create new cross-chain NFTs. To breed and produce cross-chain NFTs.
- Chainlink VRF - To generate rarity.
- Chainlink Automation - To fetch the generated NFT using Log Trigger. To swap Native currency to LINK for renewing subscriptions using Custom Value Trigger.
- Chainlink Data Feeds - To purchase power-ups using any token.(For this hackathon) Will be implemented for mint fee too (post-hackathon).
When the user provides a prompt to create a new NFT, the smart contract calls ChainlinkVRF (Direct Funding) to get a random number for rarity. The fulfillRandomWords callback function triggers the Chainlink Functions code that generates the new ZexCraftNFT using MidjourneyAI. Since the AI generation cannot be completed within the Functions run-time of 10 seconds, it returns the AI generation seed as the return value which emits an event in the fulfillRequest callback function. This event is listened by the Log Trigger Automation and triggers the performUpkeep function which calls the Chainlink Functions code that fetches the generated ZexCraftNFT. This generated NFT is stored on IPFS using NFT.storage in the Chainlink Functions code.
Users can create NFTs cross-chain by making CCIP calls from other supported chains to Avalanche by Transfer Tokens + Data. User pays the mint Fee in CCIP-BnM and sends the prompt from the ZexCraftCrosschainMint contract in the foreign chain to the ZexCraftBaseChain contract in Avalanche to generate the NFT. Users can also form relationships cross-chain using CCIP by making a cross-chain call from the NFT owned account in the foreign chain to the ZexCraftRelationshipRegistry contract deployed on Avalanche by Transfer Data. The relationship registry contract validates the signatures of both the accounts and forms a new relationship on Avalanche. User can create a baby ZexCraftNFT using CCIP by making a cross-chain call from the NFT owned account in the foreign chain to the CCIPReceiver-compatible ZexCraftRelationship deployed on Avalanche by Transfer Data.
The ZexCraft contract uses Custom Logic Chainlink Upkeeps that monitors the LINK balance and subscription balances of the protocol. When the Chainlink VRF, Chainlink Automation and Chainlink Functions subscription depletes and goes below a threshold level, the performUpkeep function automatically swaps the mint fees collected to LINK tokens and renews subscription. This makes the protocol to run on it’s own without having to rely on the owner of the protocol to manage the subscription making the product more decentralised and autonomous.
Avalanche
The product draws inspiration from this suggested idea provided by Avalanche.
“Create a c-chain dApp that uses CL Functions to call generative art APIs such as stable diffusion or DallE to mint unique nfts in one, user-friendly front-end”
Our entire product is built on Avalanche for various reasons.
- Fast transactions. User friendly UX.
- Cheap gas fees. Higher revenue margin for the protocol.
- Chainlink support. Perfectly aligns with our Chainlink needs.
- More about Avalanche here…..
TheGraph Protocol
TheGraph Protocol is the heart of this project’s UI/UX. Write about schema here….
ENS
ZexCraft implements ENS resolvers to resolve the wallet address to their ENS names.
Frontend & Backend
The project is built on Next.js+TailwindCSS. I used RainbowKit+wagmi to interact with the web3 wallet. I used react-d3-tree package to create the interactive family tree in the application.
Hacky Details
- Talk about the multi-level inheritance ownership of the NFT in the family tree.
- Talk about how you solved the AI generation time issue
- Talk about how you set up the contract to autonomously manage subscription requirements.
Contract Deployments
AvalancheFuji Testnet
- ZexCraftNft - 0xAa25e4A9db1F3e493B9a20279572e4F15Ce6eEa2
- ZexCraftERC6551Implementation - 0x1a047212AA2B57a4D52cA0c6876021f53aB89C66
- ZexCraftERC6551Registry - 0xF1D62f668340323a6533307Bb0e44600783BE5CA
- ZexCraftBaseChain - 0x2BB1f234D6889B0dc3cE3a4A1885AcfE1DA30936
- ZexCraftRelationshipImplementation - 0x649d81f1A8F4097eccA7ae1076287616E433c5E8
- ZexCraftRelationshipRegistry - 0xFD6a2699FFd3293c646498388077B66b2e459130
EthereumSepolia Testnet
- ZexCraftCrosschainMint -
- ZexCraftERC6551ImplementationCrosschain -
- ZexCraftERC6551RegistryCrosschain -
PolygonMumbai Testnet
- ZexCraftCrosschainMint -
- ZexCraftERC6551ImplementationCrosschain -
- ZexCraftERC6551RegistryCrosschain -
BinanceSmartChain Testnet
- ZexCraftCrosschainMint -
- ZexCraftERC6551ImplementationCrosschain -
- ZexCraftERC6551RegistryCrosschain -
BaseGoerli Testnet
- ZexCraftCrosschainMint -
- ZexCraftERC6551ImplementationCrosschain -
- ZexCraftERC6551RegistryCrosschain -
EthereumSepolia Testnet
- ZexCraftCrosschainMint -
- ZexCraftERC6551ImplementationCrosschain -
- ZexCraftERC6551RegistryCrosschain - 0x5A6B842891032d702517a4E52ec38eE561063539
Important Links
Brainstorming and Task Management =>
Pitch Slides =>
Pitch Video =>
Live website => https://frontend-zexcraft.vercel.app
Github Org => https://github.com/ZexCraft
Chainlink Functions Subscription =>
*Chainlink Log Trigger Automation Subscription *=>
Chainlink Custom Value Automation Subscription =>
Bottom Line
I am immensely grateful to the Chainlink Team and this hackathon for this opportunity. It was a very long journey building a project of this magnitude all by myself. I took this challenge to learn, understand and have hands-on experience with the Chainlink Services. I wish to take this project forward and launch it the market. Special thanks to Frank, Bharath, (add people here) for mentoring and helping me out with issues. If anyone wants to know more about this project or wants to collab with me post hackathon, feel free to reach out to me. Thank you :)
Built With
- css
- font-awesome
- google-fonts
- hardhat
- html
- javascript
- next.js
- react
- react-d3-tree
- solidity
- tailwindcss
- thegraph
- typescript
- wagmi
Log in or sign up for Devpost to join the conversation.