NFT & API Response Mode

Overview

Once NFT data has been added against a Tag Code, it's possible to extract both the NFT data (contract, token, owner) and also the NFT metadata (name, description, image, etc) via the API Response Mode.

What this means is that with a single API call, you can verify the authenticity of the physical NFC tag, verify the owner of the NFT (blockchain owner vs. ixkio stored owner) and get the NFT metadata itself.

Example

This tutorial assumes that you already have created your Tag Code and have set the NFT contract, token and owner. are calling via the API. We are going to use the Tag Code 'q8w3sbcz' in this example.

A standard authentication API call would be :

GET https://api.ixkio.com/v1/t?x=q8w3sbcz&n=000001&e=abcde12345abcde1234

Providing the pass/fail rules are set up (see example configuration under API Mode for authentication), you would expect to see a JSON response :

{
	"xuid": "q8w3sbcz",
	"response": "Pass"
}

Now we are going to add the NFT metadata into the Response.

Step 1 : Create an Extended Data field

Extended Data fields allow additional data to be associated with Tag Groups or Tag Codes. Extended Data can be included in the API Response. To allow the NFT metadata to display in the Response, we need to create a field to put it in.

Navigate to the Active Folder level for your Tag Code, then Folder Function Panel > Data Tab. Add a field called 'NFT' with a Type of JSON.

Step 2 : Include your new Extended Data field in the API Response

In the same Active Folder, now navigate to Folder Function Panel > Response Tab. You should see the NFT Data Name in the table (if not, refresh the page). Change the dropdown to 'Add to Response' and click Update.

Step 3 : Include NFT Data in the Response

As NFT data is dynamic, we are going to use Subtags to instruct ixkio to dynamically add the data into the Response. You can do this at the Tag Group level so it affects all Tag Codes under that Group, or you can do it on a Tag Code level. We will do it at the Tag Group level here.

Navigate to the Tag Group screen for your Tag Code, then Tag Group Data > Extended. You should see your Extended Data field 'NFT'. Into here, we are going to add :

{nft_meta}

and click Update.

Step 4 : Check the Result

That's it. Now you should see the metadata also included in the API Response.

As an example (redacted to keep the example shorter) :

{
	"xuid": "uwt84pez",
	"response": "Pass",
	"NFT": {
		"contract": {
			"address": "0x1a54bba36f03ba568719103bfe6da991b4e75bd0"
		},
		"id": {
			"tokenId": "0x2",
			"tokenMetadata": {
				"tokenType": "ERC721"
			}
		},
		"title": "Ixkio NFT Robot",
		"description": "The Ixkio NFT Demonstration Robot"

	}
}

Note that the "NFT" property is the "NFT" that you named in the Extended Data field in Step 1.

Be aware that ixkio will usually provide an authentication API Response extremely quickly. However, when requesting NFT data, we use a third party API and, on rare occasions, this can create a delay in the API Response that is out of our control.

Step 5 : Verifying the NFT Owner

If you want to verify the NFT owner stored within ixkio against that of the blockchain NFT, then there are a few ways to do this. As one example, you can create two additional Extended Data fields (step 1 and 2 above) - perhaps called 'ixkio_owner' and 'bc_owner' both with a Type 'Text' instead of 'JSON'.

Then for step 3, instead of adding the nft_meta subtag, include the NFT owner (ixkio) subtag and the NFT owner (blockchain) subtags, one in each Extended Data field :

Into the ixkio_owner :

{nft_owner}

and into the bc_owner :

{nft_xowner}

This would then add the property into the JSON which can be compared.

Last updated

Copyright TabDesk Ltd 2024