Create items (NFTs, Phygitals)

Items (also know as NFTs, Phygitals, Digital IDs)

An item is represented by an NFT on the blockchain and IPFS.

Creating items

Items are created from product templates. Before creating items, you must first create a product template using the Tokenized Asset Manager or calling the createProduct mutation using the GraphQL API. After creating a product template you will have its ID. You will then use that ID to create item(s) on the blockchain.
Here is and expample GraphQl mutation.
1
mutation {
2
createItemsBatch (productId: 19, count: 5, notes: "5 new items") {
3
notes
4
nfrIds
5
transactionResults
6
timeStarted
7
timeEnded
8
}
9
}
Copied!
Here is an example curl request which will return all items
1
curl --location --request POST 'https://staging.realitems.io/graphql' \
2
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb3VudHJ5IjoiVVNBIiwidXNlcl9uYW1lIjoia2VuQHJlYWxpdGVtcy5vcmciLCJtb2JpbGUiOiIrNTEwOTMyNDkxMSIsImxhc3RfbmFtZSI6Indvb2RydWZmIiwid2FsbGV0cyI6WyIweGY0ZTVFRjdkZTE1NDQ1QmM1NEU2M0FCMmJGZEM0YkJEY2U0MmUxZkIiLCIweDlFRUNBQjRERjEzQjYzMzhBZDYwMzg4MzVlNjFEQTJENDZjMWRDQjAiXSwiYXV0aG9yaXRpZXMiOlsiU1RBTkRBUkRfVVNFUiIsIkFETUlOX1VTRVIiLCJTVVBFUl9VU0VSIl0sImNsaWVudF9pZCI6InJlYWxpdGVtc3N0YWdpbmdjbGllbnRpZCIsImF1ZCI6WyJyZWFsaXRlbXNzdGFnaW5nand0cmVzb3VyY2VpZCJdLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiaWQiOiIyIiwiZXhwIjoxNjE0OTc0Mjg3LCJmaXJzdF9uYW1lIjoia2VuIiwianRpIjoiYTc0MGIyY2YtYWRmOC00MjQ0LWJiMTMtZTdlOGVhODQyZjI1In0.xNuUbl87rN6lCGjuJV5MWpFZR6uG-SYEA4hZv3EFes8' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{"query":"mutation {\n createItemsBatch (productId: 19, count: 5, notes: \"5 new items\") {\n notes\n nfrIds\n transactionResults\n timeStarted\n timeEnded\n }\n}","variables":{"productId":1,"count":1,"quantity":1,"notes":"item created"}}'
Copied!
If the mutation is successful the response will look something like this.
Note: The nfrIds represent the ID of each new item created.
1
{
2
"data": {
3
"createItemsBatch": {
4
"notes": "5 new items",
5
"nfrIds": "1777,1778,1779,1780,1781",
6
"transactionResults": "{\"message\":\"Successfully created 5 items\"}",
7
"timeStarted": "2021-03-04T22:27:04.732Z",
8
"timeEnded": "2021-03-04T22:27:18.741Z"
9
}
10
}
11
}
Copied!
If the mutation fails (say for insufficient energy) you will see something like this.
1
{
2
"data": {
3
"createItemsBatch": {
4
"notes": "5 new items",
5
"nfrIds": null,
6
"transactionResults": "{\"error\":\"request forbidden tx rejected: insufficient energy\\n\"}",
7
"timeStarted": "2021-03-04T22:17:53.112Z",
8
"timeEnded": "2021-03-04T22:17:59.105Z"
9
}
10
}
11
}
Copied!