DEVELOPER DOCS
Tags

Metadata Tagging

Irys supports attaching metadata tags to each transaction.

Tags can be used to:

Querying

Tags are indexed by gateways and are queryable using the Irys query package and GraphQL.

Content-Type

The Irys CLI automatically infers and sets the appropriate Content-Type (opens in a new tab) tag based on the file extension when uploading files and folders.

If your use case necessitates manual Content-Type tag setting, you can specify it during the upload process. Doing so will override the default behavior and apply the Content-Type you provided.

// Your file
const fileToUpload = "./myImage.png";
 
// Add a custom Content-Type tag
const tags = [{ name: "Content-Type", value: "image/png" }];
 
try {
	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);
}

You can also add tags via the CLI's -t option, followed by a series of name / value pairs

irys upload myImage.png -t tagName1 tagValue1 tagName2 tagValue2 -n mainnet -t matic -w bf20......c9885307

Additional Uses

There are no limits on the number of tags you can append to your files or folders. You're free to add as many tags as you wish, enabling the construction of semi-relational models within your data.

A popular practice involves creating an application-id tag, this tag helps segregate your uploads from others.

// Your file
const fileToUpload = "./myNFT.png";
 
const tags = [{ name: "application-id", value: "NFTs To The Moon" }];
 
try {
	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);
}