How to use Underdog JS to mint NFTs for each view or listen of a digital asset

Problem to solve:

The digital art and music industry lacks a comprehensive solution to track and preserve the history of digital assets. Currently, there is no reliable way to authenticate views or listens to digital pieces, and artists and musicians often struggle to establish a clear provenance trail for their work. This absence of transparency and accountability hinders the value and context of digital assets, leaving creators without a means to showcase audience engagement.

Possible solution:

Introducing a platform that employs NFTs to meticulously track and document the history of digital assets. Each time someone views or listens to a piece, a unique NFT is minted, creating an immutable record of interactions. This process addresses provenance concerns and offers several benefits:

  • It generates a provable trail of engagement with the artist's work, enhancing the value of their creations by showcasing real-time interactions and contextualizing their journey.
  • It caters to artists, musicians, collectors, and individuals invested in the history and context of digital assets.
  • Artists gain a stronger connection with their audience, while collectors and enthusiasts enjoy a heightened understanding of the asset's journey.

Resources:

  • https://github.com/UnderdogProtocol/js


Getting Started
  • yarn add @underdog-protocol/js

Add API Route

// pages/api/underdog/[...underdog].

Example

import { NextUnderdog, NetworkEnum } from "@underdog-protocol/js";

export default NextUnderdog({
 apiKey: process.env.UNDERDOG_API_KEY,
 network: NetworkEnum.Devnet,
});

Add React Hook

// components/Component/index.tsx

import { useNft, GetNftInput } from "@underdog-protocol/js"

export default function Component() {
 const { nft, loading, refetch } = useNft({
   type: {
     transferable: false,
     compressed: true,
   },
   projectId: 1,
   nftId: 0,
 });

 if (!nft || loading) return null;

 return <p>{nft.name}</p>;
}

Cache Underdog State

// pages/_app.tsx

import { AppProps } from "next/app";
import { UnderdogProvider } from "@underdog-protocol/js";

export default function App({ Component, pageProps }: AppProps) {
 return (
   <UnderdogProvider>
     <Component {...pageProps} />
   </UnderdogProvider>
 );

This code will mint a new NFT to the recipient address for each view or listen of the digital asset. You can use this code in a variety of ways, such as:

  • Integrating it with a media player to mint an NFT each time someone plays a song or video.
  • Using it to mint an NFT each time someone views a digital artwork.
  • Using it to mint an NFT each time someone interacts with a decentralized application.

By using Underdog JS to mint NFTs for each view or listen of a digital asset, you can create a more transparent and accountable ecosystem for digital art and music. This benefits both artists and collectors by providing a provable trail of engagement and context.

Conclusion

Underdog JS is a powerful tool that can be used to mint NFTs for each view or listen of a digital asset. This can help to create a more transparent and accountable ecosystem for digital art and music, benefiting both artists and collectors.