paritytech / capi

[WIP] A framework for crafting interactions with Substrate chains
https://docs.capi.dev
Apache License 2.0
105 stars 10 forks source link

Capture NFT Pattern Library #242

Closed jainkrati closed 1 year ago

jainkrati commented 1 year ago

A continuations of https://github.com/paritytech/capi/issues/222 This is a work in progress

Use cases of the NFT Pattern Library:

Along with some psuedocode

  1. Create conditionally owned NFTs : Example includes booster NFTs in a game, priviledge NFTs above a particular score in a test
    import * as C from "../mod.ts";
    const xNFTAddress = await C.nft.create({"conditional", ownershipEvaluatorFunction});
    console.log(xNFTAddress);
  2. Create fractionally owned NFTs : Examples include an event NFT owned fractionally by all attendees, Photo NFT owned by everyone who was in the photo
    const xNFTAddress = await C.nft.create({"fractional"});
  3. Create rentable NFTs / subscription based NFTs : Examples include metaverse land lease / renting power-ups/add-on in a game
    const xNFTAddress = await C.nft.create({"rentable", rent});
  4. Create generative NFTs : These are NFTs that change asset/attributes as time or ownership changes
    const xNFTAddress = await C.nft.create({"generative", generativeAssetID});
  5. Create on-chain NFTs: These NFTs store all the assets (like image/text/audio) on chain; examples include Proof Of Attendance Picture (POAP) , Appreciation/Kudos NFTs, Gift Voucher NFTs where owner's name and other details are the on chain content in the NFT
    const xNFTAddress = await C.nft.create({"onChain", dynamicSVG});
  6. Mint and Transfer NFTs
    await C.nft.mint(xNFTAddress, ownerAddress);
  7. Get NFT attribute : Useful for token gating access on basis of attribute value
    await C.nft.get(attributeName);
  8. Get all token holders
    await C.nft.getHolders(xNFTAddress);

So how does it work behind the scenes?

We can either use an existing library like rmrk or we can create NFT constructs from scratch. This is open for discussion.

Reference links

  1. https://www.rmrk.app/
  2. https://enjin.io/blog/efinity
  3. https://unique.network/
  4. https://unqnft.io/
harrysolovay commented 1 year ago

We'll need to scope this down / consider what is feasible given the constraints of the uniques pallet. We wouldn't want to bake in too many opinions. Will leave this as a broad TODO for pattern lib development (not to be in Capi's core).