How to Use 2 NFTS metadata to create a new NFT (Breed) with Metadata JSON that they choose from the 2 NFTs.
-
What's the problem exactly? Metadata is off-chain so you could write a backend service that takes the metadata and create a new one combining them.– Ismael ♦May 17, 2022 at 8:00
-
Thanks Ismael but am new to it so I don't have an exact idea of how to do that. Any code samples to help me understand and do that .– new programmerMay 17, 2022 at 9:46
-
Sorry, but I don't know any sample that does something similar. Anyway it sounds easy to do for a novice programmer: take two json files a create a new one. Use your favorite programming language like python, java, c# or javascript.– Ismael ♦May 17, 2022 at 15:10
1 Answer
There is no specific way to do this. It's really up to you. One way could be to take the two input metadata and make a biased random generator that favors the input traits. Another way is to convert the metadata into numerical values and then average the two. Perhaps add in some randomness though because the traits will eventually average out over the generations.
CryptoZombies is a free course that teaches you to build games on Ethereum using Solidity. In lesson 2, chapter 8, they average the zombie dna to create a new zombie:
function testDnaSplicing() public {
uint zombieDna = 2222222222222222;
uint targetDna = 4444444444444444;
uint newZombieDna = (zombieDna + targetDna) / 2;
// ^ will be equal to 3333333333333333
}