Ternoa indexer is a record of the Ternoa Chain data. You can query data for some specific entities (NFT, Collection, Marketplace(...)) using GraphQL. In this example, we use the graphql-request library.
Step 1: NftEntity query preparation
You first need to prepare a stringified query to get NFT data from a specific NFT id. Here are detailed the parameters available for the NftEntity:
`nftId`: The NFT id. - String`auction`: The auction data if the NFT is auctioned; null otherwise. - AuctionEntity | null`collection`: The collection data if the NFT is in a collection; null otherwise. - CollectionEntity | null`owner`: The NFT owner; null if the NFT is burned. - String | null`creator`: The NFT creator. - String`delegatee`: The delegatee address if the NFT is delegated; null otherwise. - String | null`royalty`: - The NFT royalty. - Number`offchainData`: The NFT off-chain data (e.g. IPFS CID hash, a link, or any string). - String!`secretOffchainData`: The Secret NFT off-chain data (e.g. IPFS CID hash, a link, or any string) if the NFT is a Secret NFT; null otherwise. - String | null
`capsuleOffchainData`: The Capsule NFT off-chain data (e.g. IPFS CID hash, a link, or any string) if the NFT is a Capsule NFT; null otherwise. - String | null
`isCapsule`: Boolean flag: true if the NFT is a Capsule NFT; false otherwise. - Boolean`isCapsuleSynced`: Boolean flag: true if the NFT is a synced Capsule NFT; false otherwise. - Boolean`isSecret`: Boolean flag: true if the NFT is a Secret NFT; false otherwise. - Boolean`isSecretSynced`: Boolean flag: true if the NFT is a synced Secret NFT; false otherwise. - Boolean`isDelegated`: Boolean flag: true if the NFT is delegated; false otherwise. - Boolean`isTransmission`: Boolean flag: true if a transmission protocol is set for the NFT; false otherwise. - Boolean`isSoulbound`: Boolean flag: true if the NFT is a Soulbound NFT; false otherwise. - Boolean`isListed`: Boolean flag: true if a transmission protocol is set for the NFT; false otherwise. - Boolean`isRented`: Boolean flag: true if a transmission protocol is set for the NFT; false otherwise. - Boolean`rentee`: The rentee address if the NFT is rented; null otherwise. - String | null`rentalContract`: The rental contract data if the NFT is rented; null otherwise. - RentEntity | null`price`: The sale listing price in BN value if the NFT is listed for a direct sale; null otherwise. - String | null`priceRounded`: The sale listing price if the NFT is listed for a direct sale; null otherwise. - Number | null`marketplace`: The marketplace data if the NFT is listed; null otherwise. - MarketplaceEntity`typeOfListing`: The NFT listing type if the NFT is listed (sale or auction); null otherwise. - String | null`transmissionRecipient`: The recipient address to whom the NFT will be transmitted if a transmission protocol is defined for the NFT; null otherwise. - String | null
`transmissionProtocol`: - The transmission protocol data if a transmission protocol is defined for the NFT; null otherwise. TransmissionEntity | null
`timestampCreated`: - The creation timestamp. Date`timestampBurned`: - The burning timestamp. Date | null`timestampListed`: - The last listing timestamp. Date | null`timestampRented`: - The last renting timestamp. Date | null`timestampSecretAdded`: The last secret addition timestamp. - Date | null`timestampConvertedToCapsule`: The last capsule conversion timestamp. - Date | null
For example, if we want to get the Secret NFT: owner / id / off-chain data / secret off-chain data / isSecret state / collection id / royalty; we have to prepare the following query by replacing NFT_ID with the Secret NFT id you want to get the information from (e.g. the NFT id from the Secret NFT minted previously in "How to mint a Secret NFT on-chain"):
The getNftData function is an asynchronous function that sends a GraphQL request using the request function from the "graphql-request" library. Here we are using the Ternoa Alphanet instance at "https://indexer-alphanet.ternoa.dev" with the NFT ID 0 as the query parameter (you can try with your id). The response from the server is an object with a property nftEntity that has the data of the requested NFT entity.
The response for the NFT id 74,260 the Alphanet Network is:
How to retrieve the last NFT minted using Ternoa Indexer
Ternoa Indexer comes with filtering and ordering options. Instead of requesting a single NftEntity with a specific NFT ID, you can filter all NftEnties: