NFTs with multiple files
NFTs are data containers where you can add properties and also files. You can include an image, video, audio, etc... just add a pointer to the file in IPFS and some properties to describe it.

NFT layers
In the following example, we are creating a collection where every NFT will have one image used as a thumbnail and two video files, one in 8K and the other in SD (Standard Definition). This is just an example, and you can add whatever property you need to describe your files.
We are adding
files
inside metadata
and setting four properties for the files: name
, media_type
, src
, resolution
and duration
. With this, we are just saying that every file will have those properties and must be defined during the token creation.The
media_type
is required by the standard (CIP25). The
src
can be a base64 encoded image or an image that is already pinned in IPFS, for example, ipfs://QmP4sEnaYa1fhLTFVTUq5E8d8XvEtxBS7NE5M3TACUtSxh
or through an IPFS gateway https://ipfs.io/ipfs/QmP4sEnaYa1fhLTFVTUq5E8d8XvEtxBS7NE5M3TACUtSxh
. You can also add an image hosted in a webserver, for example, https://www.example.com/myimage.pngPOST /<app-id>/v1/nft/collections HTTP/1.1
Host: cardano-testnet.tangocrypto.com
x-api-key: <your-api-key>
Content-Type: application/json
{
"name": "Files Collection",
"description": "Tango colletion with files",
"url": "https://www.tangocrypto.com",
"payout_address": "addr_test1qp9mj7vnenx4v99hw7ztfq03n7dmmujpgtlyfjhhel9w67nk72usllcew208n60ym94xcptfrgytuy5apwp565x28jgsg0ztq3",
"policy": {
"lock": true,
"lock_time": "2023-02-24"
},
"metadata": {
"asset_name": "<asset_name>",
"name": "<name>",
"image": "<image_link>",
"mediaType": "<mime_type>",
"description": "<description>",
"files": {
"name": "<file_name>",
"mediaType": "<mime_type>",
"src": "<src>",
"resolution": "<resolution>",
"duration": "<duration>"
},
"attributes": {
"color": "<color>",
"right_eye": "<right_eye>",
"left_eye": "<left_eye>",
"mouth": "<mouth>",
"collection": "Faces Collection",
"artist": "Tangocrypto",
"twitter": "https://twitter.com/tango_crypto",
"copyright": "Tangocrypto 2022"
},
"version": "1.0"
}
}
When we create the NFT we have to define all the values for the properties we defined in the collection using tags. Therefore for both files we have to define the
name
, media_type
, src
, resolution
and duration
. POST /<app-id>/v1/nft/collections/<collection-id>/tokens HTTP/1.1
Host: cardano-testnet.tangocrypto.com
x-api-key: <your-api-key>
Content-Type: application/json
{
"tokens": [{
"asset_name": "FACE#01",
"name": "FACE 01",
"description": "Faces collection",
"media_type": "image/png",
"custom_attributes": {
"md5checksum": "b58e62a83802b2bf0792a4e983dd2ff3cf9e0c1e",
"artist": "Pepe"
},
"image": "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0C...AABmJLR0QA/wD/AP+gvaeTAAAe40",
"files": [{
"metadata_attributes": [{
"tag": "<file_name>",
"name": "File name",
"value": "8K (Full Ultra HD)"
},
{
"tag": "<mime_type>",
"name": "Mime type",
"value": "video/mp4"
},
{
"tag": "<src>",
"name": "File link",
"value": "ipfs://QmbR6vfPA9qrfpU5Zm81k5SMRdhE9yUVpCKPErGrbs8Nc"
},
{
"tag": "<resolution>",
"name": "Resolution",
"value": "4320p"
},
{
"tag": "<duration>",
"name": "Duration",
"value": "3:24"
}
],
"custom_attributes": {
"dimensions": "7680x4320"
}
},
{
"metadata_attributes": [{
"tag": "<file_name>",
"name": "File name",
"value": "SD (Standard Definition)"
},
{
"tag": "<mime_type>",
"name": "Mime type",
"value": "image/gif"
},
{
"tag": "<src>",
"name": "File link",
"value": "ipfs://QmbR6vfPA9qrfpU5Zm81k5SMRdhE9yUVpCKPErGrbs7Py"
},
{
"tag": "<resolution>",
"name": "Resolution",
"value": "480p"
},
{
"tag": "<duration>",
"name": "Duration",
"value": "1:10"
}
],
"custom_attributes": {
"dimensions": "640x480"
}
}
],
"metadata_attributes": [{
"tag": "<color>",
"name": "Attribute color",
"value": "Light Blue"
},
{
"tag": "<left_eye>",
"name": "Attribute left eye",
"value": "Open"
},
{
"tag": "<right_eye>",
"name": "Attribute right eye",
"value": "Half"
},
{
"tag": "<mouth>",
"name": "Attribute mouth",
"value": "Astonishmed"
}
]
}
]
}
Response
{
"data": [{
"id": "01g7xagzc3pcc8mdb9tjc7beb3",
"asset_name": "FACE#01",
"name": "FACE 01",
"fingerprint": "asset1aqncgpstuj44cwjr4v6xuhajmphu2nzn6euhqp",
"status": "FOR_SALE",
"description": "Faces collection",
"image": "ipfs://QmP8CpUvrsRkP4KvuUdPhoMcfTnCDKiH6CpW9Nq22ZVRmL",
"media_type": "image/png",
"files": [{
"metadata_attributes": [{
"name": "File name",
"value": "8K (Full Ultra HD)",
"tag": "<file_name>"
}, {
"name": "Mime type",
"value": "video/mp4",
"tag": "<mime_type>"
}, {
"name": "File link",
"value": "ipfs://QmbR6vfPA9qrfpU5Zm81k5SMRdhE9yUVpCKPErGrbs8Nc",
"tag": "<file_link>"
}, {
"name": "Resolution",
"value": "4320p",
"tag": "<resolution>"
}, {
"name": "Duration",
"value": "3:24",
"tag": "<duration>"
}],
"custom_attributes": {
"dimensions": "7680x4320"
}
}, {
"metadata_attributes": [{
"name": "File name",
"value": "SD (Standard Definition)",
"tag": "<file_name>"
}, {
"name": "Mime type",
"value": "image/gif",
"tag": "<mime_type>"
}, {
"name": "File link",
"value": "ipfs://QmbR6vfPA9qrfpU5Zm81k5SMRdhE9yUVpCKPErGrbs7Py",
"tag": "<file_link>"
}, {
"name": "Resolution",
"value": "480p",
"tag": "<resolution>"
}, {
"name": "Duration",
"value": "1:10",
"tag": "<duration>"
}],
"custom_attributes": {
"dimensions": "640x480"
}
}],
"policy": {
"lock": true,
"lock_time": "2023-02-24T00:00:00.000Z",
"policy_id": "cc013f90388783b72578d7996685cb9b757563b11f6a5957b7d8b790",
"script": {
"type": "all",
"scripts": [{
"type": "sig",
"keyHash": "18883d1b1bac446687aef2d80942834037be75ed03bde5590cfbf0b2"
}, {
"type": "before",
"slot": 82827501
}]
}
},
"metadata": {
"721": {
"version": "1.0",
"cc013f90388783b72578d7996685cb9b757563b11f6a5957b7d8b790": {
"FACE#01": {
"image": "ipfs://QmP8CpUvrsRkP4KvuUdPhoMcfTnCDKiH6CpW9Nq22ZVRmL",
"copyright": "Tangocrypto 2022",
"color": "Light Blue",
"artist": "Pepe",
"left_eye": "Open",
"description": "Faces collection",
"mediaType": "image/png",
"collection": "Faces Collection",
"right_eye": "Half",
"twitter": "https://twitter.com/tango_crypto",
"mouth": "Astonishmed",
"md5checksum": "b58e62a83802b2bf0792a4e983dd2ff3cf9e0c1e",
"name": "FACE 01",
"files": [{
"name": "8K (Full Ultra HD)",
"duration": "3:24",
"mediaType": "video/mp4",
"src": "ipfs://QmbR6vfPA9qrfpU5Zm81k5SMRdhE9yUVpCKPErGrbs8Nc",
"resolution": "4320p",
"dimensions": "7680x4320"
}, {
"name": "SD (Standard Definition)",
"duration": "1:10",
"mediaType": "image/gif",
"src": "ipfs://QmbR6vfPA9qrfpU5Zm81k5SMRdhE9yUVpCKPErGrbs7Py",
"resolution": "480p",
"dimensions": "640x480"
}]
}
}
}
},
"created_at": "2022-07-14T03:02:35.139Z",
"updated_at": "2022-07-14T03:02:41.872Z"
}],
"cursor": ""
}
If you get the metadata information from this NFT using Cardanoscan.io you'll see something like this

Last modified 10mo ago