Build
ONCHAIN STORAGE
Features
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 GraphQL.

Content-Type

Irys automatically infers and sets the appropriate Content-Type (opens in a new tab) tag based on the file extension when uploading files and folders. You can also manually set the Content-Type tag, doing so will override the default behavior and apply the value you provide.

// 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 \
  -n testnet \
  -t ethereum \
  -w bf20......c9885307 \
  --tags tagName1 tagValue1 tagName2 tagValue2 \
  --provider-url https://rpc.sepolia.dev

Additional Uses

You can add up to 20 tags to each transaction, 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);
}