HANDS ON
NFT licensing and UDL

Define NFT licensing with the UDL

In this tutorial, you'll learn how to attach a Universal Data License (UDL) (opens in a new tab) to an NFT.

The UDL is a parameterized license you can use to explicitly define how you allow your content to be used.

Overview

Purchasing an NFT not only gives you ownership of the token itself but, depending on the collection, may also grant certain rights over the underlying intellectual property. These rights cover things like creating derivative works or merchandising the artwork on items such as t-shirts. Each NFT collection varies in the rights it provides to its token holders (opens in a new tab) and historically, there hasn't been a standard license attached to NFTs.

With the UDL creators now have a simple, customizable license they can easily attach to NFT metadata at upload that spells out the permissions they grant to the token holders.

Adding UDL to NFTs

Creating an NFT is (generally) a four step process:

  1. Upload the visual asset (image or video)
  2. Embed the URL to the visual asset in a metadata file
  3. Upload the metadata file
  4. Use the link to the metadata when minting the NFT

For more details on this, we have a separate tutorial.

When uploading the metadata, you can attach a UDL in the form of tags with name / value pairs.

If you’re using our NodeJS SDK to upload your metadata files, you can modify your upload script to include the UDL parameters. Not all UDL tags are required (opens in a new tab), and the ones you use will depend on how you want to allow your content to be used. The script below demonstrates how to add common tags to a metadata file upload, when using it for your own project, customize as needed.

import Irys from "@irys/sdk";
import * as fs from "fs";
import dotenv from "dotenv";
dotenv.config();
 
// Returns a reference to an Irys node
const getIrys = async () => {
	const network = "devnet";
	// Devnet RPC URLs change often, use a recent one from https://chainlist.org/
	const providerUrl = "";
	const token = "ethereum";
	const privateKey = process.env.PRIVATE_KEY;
 
	const irys = new Irys({
		network, // "mainnet" || "devnet"
		token, // Token used for payment
		key: privateKey, // ETH or SOL private key
		config: { providerUrl }, // Optional provider URL, only required when using Devnet
	});
	return irys;
};
 
// Path to metadata file
const fileToUpload = "./metadata.json";
 
// Define the Tag type
type Tag = {
	name: string;
	value: string;
};
 
// Define your unique license
const tags: Tag[] = [
	{ name: "Content-Type", value: "application/json" },
	{ name: "Contract", value: "0xd9145CCE52D386f254917e481eB44e9943F39138" },
	{ name: "Payment-Mode", value: "Global-Distribution" },
	{ name: "License", value: "yRj4a5KMctX_uOmKWCFJIjmY8DeJcusVk6-HzLiM_t8" },
	{ name: "License-Fee", value: "Monthly-1" },
	{ name: "Derivation", value: "Allowed-With-Credit" },
	{ name: "Commerical-Use", value: "Allowed" },
	{ name: "Currency", value: "ETH" },
];
 
// Upload the metadata with UDL tags
const uploadMetadata = async () => {
	try {
		const irys = await getIrys();
		const response = await irys.uploadFile(fileToUpload, { tags: tags });
		console.log(`File uploaded ==> https://gateway.irys.xyz/${response.id}`);
	} catch (e) {
		console.log("Error uploading file ", e);
	}
};
uploadMetadata();

Using the provenance toolkit

You can also use the Irys Provenance Toolkit repository which provides a simple graphical interface.

  1. Fork or clone the repository (opens in a new tab)
  2. Use the Uploader component to upload your visual assets
  3. Use the UDL Uploader component to upload your metadata file