# NFT 2.O 枚举函数

### CRC 721

#### `ownerOf(uint256 tokenId)`

返回持有索引为`tokenId`的 NFT  的地址。

#### `tokenByIndex(uint256 index)`

合约按铸造顺序保存一个 token id 数组`_allTokens`，返回其中第`index`个 NFT 的 token id。

#### `tokenOfOwnerByIndex(address owner, uint256 index)`

合约将地址与其持有的全部 NFT 的 token ids 保存在一个`_ownedTokens` mapping，此函数返回地址`owner`持有的，`_ownedTokens`所保存的第`index`个 NFT 的 token id。

#### `tokens(uint256 offset, uint256 limit)`

返回`_allTokens`中指定索引范围内的所有 NFT 的 token ids，范围从`_allTokens[offset]`到`_allTokens[`offset + limit`]`。

#### `tokensOf(address owner, uint256 offset, uint256 limit)`

返回`_ownedTokens`保存的`owner`所持有的 token ids 数组中，指定范围内的 token ids，范围从`_ownedTokens[owner].at(offset)`到`_ownedTokens[owner].at(offset+limit)`。

#### `totalSupply()`

返回该合约所发行的全部 NFT 的数量。

### CRC 1155

#### `balanceOfBatch(address[] memory accounts, uint256[] memory ids)`

接受长度相同的 `accounts` 和 `ids` 数组为参数，返回值为一个与输入参数等长的数组，`balanceOfBatch[i]` 的值为地址 `accounts[i]` 所持有的索引为 `ids[i]`的 NFT 数量。此函数适用于同质化场景，开发者可自行斟酌是否使用。

#### `exists(uint256 tokenId)`

索引为`tokenId`的 NFT 是否存在。

#### `tokenByIndex(uint256 index)`

合约按铸造顺序保存一个 token id 数组`_allTokens`，返回其中第`index`个 NFT 的 token id。

#### `tokenCountOf(address owner)`

返回地址`_owner`所持有的所有 NFT 数量。

#### `tokenOfOwnerByIndex(address owner, uint256 index)`

合约将地址与其持有的全部 NFT 的 token ids 保存在一个`_ownedTokens` mapping，此函数返回地址`owner`持有的，`_ownedTokens`所保存的第`index`个 NFT 的 token id。

#### `tokens(uint256 offset, uint256 limit)`

返回`_allTokens`中指定索引范围内的所有 NFT 的 token ids，范围从`_allTokens[offset]`到`_allTokens[`offset + limit`]`。

#### `tokensOf(address owner, uint256 offset, uint256 limit)`

返回`_ownedTokens`保存的`owner`所持有的 token ids 数组中，指定范围内的 token ids，范围从`_ownedTokens[owner].at(offset)`到`_ownedTokens[owner].at(offset+limit)`。

#### `totalSupply()`

返回该合约所发行的全部 NFT 的数量。

#### `totalSupply(uint256 tokenId)`

返回索引为`tokenId` NFT 的数量，适用于同质化场景，开发者可自行斟酌是否使用。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://conflux-technical-support.gitbook.io/conflux-nft-kai-fa-zhi-nan/he-yue-mei-ju-han-shu-shuo-ming/nft-2.o-mei-ju-han-shu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
