Skip to content

Instantly share code, notes, and snippets.

@jcnelson
Last active September 9, 2022 08:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcnelson/8c5f89c29192166a4a37f2b807ed1431 to your computer and use it in GitHub Desktop.
Save jcnelson/8c5f89c29192166a4a37f2b807ed1431 to your computer and use it in GitHub Desktop.
NFTrees: a Mineable, Stackable NFT

NFTrees

EDIT: So, I went ahead and built this out. Enjoy! https://github.com/jcnelson/nftree

Instead of minting NFTs as they are purchased, an NFT project can instantiate them all on chain through a new NFT data structure called an NFTree. An NFTree is an authenticated filesystem of NFTs, composed of files (the NFTs themselves) organized into a hierarchy of directories. There is a root directory that contains all NFTs and other directories. Each directory contains the Merkle root of a Merkle tree constructed over its immediate children, thereby ensuring that each directory cryptographically represents its subtree in the filesystem.

Each file in the NFTree commits to the following metadata about the NFT:

  • Its cryptographic hash
  • Its size, in bytes
  • Its cost, in tickets (see below)

Each directory in the NFTree commits to the following additional metadata:

  • The root of the Merkle tree constructed over its children NFTs and directories
  • The sum of its childrens' sizes
  • The sum of its childrens' costs, in tickets

The root of an NFTree is a directory, but by the above construction, it represents not only all contained NFTs, but also their combined size and economic worth.

Representing an NFT collection this way confers the following benefits:

  • Decentralized emission. The NFT collection creator simply mints the single NFTree. People buy individual NFTs or whole directory trees of them by submitting purchase request for the NFT (or directory), as well as a Merkle proof that proves that it exists within the NFTree. Then, NFTs are instantiated only once someone is willing to buy them.

  • Scalable purchases. An NFT buyer does not need to purchase individual NFTs. Instead, they can purchase a whole directory of NFTs, which includes all of its descendant directories and their NFTs. The act of doing so splits off the directory into its own NFTree (rooted at that directory) from its parent. This happens within a single transaction that purchases all contained NFTs at once. In this document, we call the resulting NFTree a "sub-NFTree."

  • Efficient Recombination. An NFT owner can efficiently reorganize and recombine NFTs and NFTrees into a new NFTree on-chain by (a) burning the original owned NFTs and NFTrees and (b) re-instantiating them in a new NFTree from the NFT data with the new desired organization. They can then host off-chain the Merkle proofs that prove to any would-be buyers that the original NFTs and NFTrees are all represented in the new NFTree.

Mining NFTs

Because the NFTree can represent an unbound number of NFTs, it does not permit the first-sale of all NFTs (or sub-NFTrees) at once. Instead, it throttles their minting so that would-be users have a chance to discover and participate in the NFT project (note that an NFTree that does not throttle on its own will inevitably be throttled by the blockchain block limit). To do so, the NFTree would require that up to a fixed number of NFTs can be sold off of the original NFTree in one Stacks block. In this manner, NFT buyers are not buying NFTs, but are mining them.

To mine an NFT, would-be buyers submit STX to the NFTree contract with a bid to acquire that Stacks block's allotment of NFTs off of the NFTree. At most one buyer would be granted the right to claim that block's allotment of NFTs, with a probability proportional to the fraction of STX they committed. If they win the NFT allotment, then they can claim up to that number of NFTs (or sub-NFTrees) once the contract determines the winner.

The act of successfully mining does not grant the NFT right away; it instead grants the buyer a number of tickets to claim NFTs off of the NFTree at a later date. This amount of tickets a user owns can be accumulated over multiple mining attempts, and used to purchase larger and larger sub-NFTrees. For example, if there was an NFTree project that permitted purchase at most 100 NFTs per Stacks block, but it contained a sub-NFTree with 1,000 NFTs, then a would-be buyer would need to successfully win 10 NFTree blocks in order to earn the right to claim the 1,000-piece sub-NFTree.

The ticket concept is inspired by game tickets in an arcade. A user inserts tokens (STX) to play arcade games (mining) to earn tickets, and then later redeems the tickets for prizes (NFTs, NFTrees) whose price is denominated in these tickets. The tickets are not tokens -- they are fungible, but non-transferrable, and can only be redeemed by the owner for available NFTs.

Stacking NFTs

Launching a collection of NFTs as an NFTree offers both the creator and owners a unique revenue generation model: owners can stack their NFTs (and sub-NFTrees) for a STX yield. By locking them up into the NFTree contract -- i.e. making it so that they cannot be re-sold during the lock period -- they can elect to receive a fraction of the STX used to purchase NFTs off the NFTree during the lock-up.

The act of buying an NFT or sub-NFTree starts with the act of paying STX for it to the NFTree smart contract. Regardless of who wins the tickets to claim the NFT, the STX gets split between the project creator and the NFT stackers. A fraction of the STX goes directly to the project creator, and the remainder gets split among the stackers.

In addition, the NFTree contract can optionally charge a royalty for each NFT (or sub-NFTree) that gets re-sold, and distribute the STX to both the project creator and the stackers. This is not required for stacking to work, but for smaller NFTree collections, this may offer a more sustainable revenue stream. The decision to do this is project-specific.

The amount of STX yield an NFT stacker gets is proportional to the number of tickets their NFTs are worth. They receive a fraction of STX equal to the fraction of tickets their NFTs represent.

Economic Advantages

In addition to the benefits of representing NFTs as an NFTree, the act of mining and stacking them confer the following economic advantages to participants over existing NFT systems:

  • Floor Price. Because an NFT can be stacked for positive yield, there exists a floor price for its resale -- it's simply the discounted cash flow valuation of the stacked NFT.

  • Avoids Saturation. Because NFT minting is driven by mining, and because NFT owners can lock up their NFTs for a yield, the number of NFTs in the collection available for resale will grow and shrink with market demand.

@cuevasm
Copy link

cuevasm commented Mar 7, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment