AI Network
  • What is AI Network
  • AIN Blockchain
    • Architecture
      • Design Principles
      • Event-driven Architectures
      • Blockchain Database
        • States
          • State Types
          • Operations
          • Predefined Structures
        • Rules and Owners
          • Rule Configs
          • Owner Configs
        • Functions
          • Built-in Functions
      • Instant Execution, and Eventual Consistency
      • Network ID and Chain ID
      • Transactions
        • Structure
        • Nonce
        • Read Concern
        • Propagation
      • Block Structure
      • Account and Keys
      • Consensus
      • Scalability
      • Apps
    • Developer Guide
      • Quick Start
      • AI Network Products
        • AI Network Worker
        • AI Network Insight
        • Testnet Server Node
        • Ainize Trigger
          • Project user
          • Project deployer
          • Why do we have to use Ainize Trigger?
      • Token Bridge
      • Trouble Shooting
    • Developer Reference
      • Blockchain API
        • JSON RPC API
        • Node Client API
      • Blockchain SDK
        • ain-js
        • ain-py
      • Validators
    • Staking
  • AIN DAO
    • What is AIN DAO
      • Runo (Run Your Node)
      • GPU Sponsorship Program
    • Onboarding & Participation
    • Governance
    • Tokenomics
      • AI Network Tokenomics
      • AINFT Tokenomics
  • AI Agents
    • AINFT
    • AINFT Factory
    • AINFT Projects
      • 🍳MiniEggs
      • 🦈Baby Shark
      • 🛸Soul Fiction
      • 🎻NFT Classics Society
    • Developer Reference
      • Ainft-Js
      • AINFT tutorial
        • Create AINFT object and Mint
        • Transfer AINFT
        • Set metadata of AINFT
        • Search and Retrieve AINFT
  • AIN Wallet
    • What is AIN Wallet?
    • AIN Wallet API
  • PROPOSAL DOCUMENTS
    • AIN Improvement Memos (AIMs)
    • AIN Improvement Proposals (AIPs)
Powered by GitBook
On this page
  • Retrieve AINFTs
  • Search Ainft object and AINFTs
  • Limit

Was this helpful?

  1. AI Agents
  2. Developer Reference
  3. AINFT tutorial

Search and Retrieve AINFT

This tutorial describe how to retrieve AINFTs by id, name, symbol and userAddress.

Retrieve AINFTs

You can retrieve AINFTs using geAinftsByAccount or getAinftsByAinftObject .

ainftJs.nft.getAinftsByAccount(userAddress)
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	})
ainftJs.nft.getAinftsByAinftObject(ainftObjectId)
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	})

Search Ainft object and AINFTs

Also, you can search ainft objects or AINFTs. Search options are below.

  • ainftObjectId - The ID of Ainft object

  • name - The name of Ainft object

  • symbol - The symbol of Ainft object

  • tokenId - Token ID of AINFT

  • userAddress - Address of AINFT owner

ainftJs.nft.searchAinftObjects({ ainftObjectId })
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	});
ainftJs.nft.searchNfts({ ainftObjectId })
	.then((res) => {
		console.log(JSON.stringify(res, null, 2));
	})
	.catch((error) => {
		console.log(error);
	});

Response

// Return Type
{
	nfts: Array<{
		owner: string,
		tokenId: string,
		tokenURI: string,
		ainftObject: {
			id: string,
			name: string,
			symbol: string,
			owner: string,
		}
		metadata: object,
	}>,
	isFinal: boolean,
	cursor: string,
}

{
	ainftObjects: Array<{
		id: string,
		name: string,
		symbol: string,
		owner: string,
	}>,
	isFinal: boolean,
	cursor: string,
}

Limit

Search function retrieves 20 items by default. If you want to set number of result items, you can use limit option. Maximum limit value is 100.

const ainftObjects = await ainftJs.nft.searchAinftObjects({ limit: 5 })

then, you can retrieve more with using cursor.

const nextAinftObjects = await ainftJs.nft.searchAinftObjects({ limit: 5, cursor: '0x460e3BC2E6D98Bc2b434DE4854Bf4a08E63eb3A2' });

The cursor value is included in result of search. If you search nfts, usage is the same.

PreviousSet metadata of AINFTNextWhat is AIN Wallet?

Last updated 1 year ago

Was this helpful?