Recipes
Dynamic NFT Metadata

Dynamic NFT Metadata

With dynamic NFT metadata stored on Polybase DB, you can build new kinds of utility or gaming NFTs that need faster and cheaper NFT metadata updates.

For example, for an NFT that represents a game character's skill level, you can update the skill points every second as that character does actions in the game. Or for a verifiable credential NFT, you can update it everytime a user finishes a lesson in an educational app.

Limitations of alternatives

  • IPFS/Arweave: updating metadata causes CID to change, additionally the data isn't indexable and queryable.
  • Tableland: updating metadata requires an Ethereum transaction, very costly and 10-15s confirmation time.
  • Ceramic: complex schema set up, no permission rules, no private data and lots of new concepts.

Get started

Example Polybase DB collection

// `public` means that the collection is public, anyone can view and read
// the records in the collection. You can still implement rules on who can 
// edit the data by defining functions on the collection.
@public
collection VerifiableCredentialMetadata {
  // `id` is unique and required on all collections
  id: string;
 
  // Use the NFT format
  name: string;
  // Image could link to the location of the file on IPFS, Arweave, etc.
  image: string;
  
  // Any additional properties you want
  level: number;
  points: number;
 
  constructor (id: string, name: string, image: string) {
    this.id = id;
    this.name = name;
    this.image = image;
    this.points = 0;
  }
 
  // You can add your own functions to determine rules
  // on who can update the data
  function setPoints (points: number) {
    // Check if the caller is a master address (or null address for immutable metadata).
    if (ctx.publicKey != '0x000000000') {
      error('You are not allowed to update the points.');
    }
    this.points = points;
  }
}

And the url to access the metadata would be:

https://testnet.polybase.xyz/v0/collections/example%2FVerifiableCredentialMetadata/records/<record ID>?format=nft`

Polybase DB Docs