> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# searchAssets

> 在 OrbitFlare 上使用 DAS searchAssets，按所有者、创作者、合集、接口、压缩状态、版税等条件搜索 Solana NFT、压缩 NFT 和代币。

## 概述

`searchAssets` 在一次查询中组合多个筛选条件。当没有任何单个 `getAssetsBy*` 方法能满足需求时使用它，例如“这个钱包持有的、属于这个合集的压缩 NFT”或“这个钱包持有的同质化代币”。

默认情况下，所有筛选条件都必须匹配（`conditionType: "all"`）。设置 `conditionType: "any"` 可匹配至少满足一个筛选条件的资产，设置 `negate: true` 可反转结果。

## 参数

### 筛选条件

<ResponseField name="ownerAddress" type="string">
  所有者钱包（base-58）。
</ResponseField>

<ResponseField name="creatorAddress" type="string">
  创作者地址（base-58）。
</ResponseField>

<ResponseField name="creatorVerified" type="boolean">
  与 `creatorAddress` 一起使用时，仅匹配已验证的创作者。
</ResponseField>

<ResponseField name="authorityAddress" type="string">
  权限地址（base-58）。
</ResponseField>

<ResponseField name="grouping" type="[string, string]">
  分组键和值，例如 `["collection", "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w"]`。
</ResponseField>

<ResponseField name="delegate" type="string">
  委托人地址（base-58）。
</ResponseField>

<ResponseField name="interface" type="string">
  资产接口，例如 `V1_NFT`、`ProgrammableNFT`、`MplCoreAsset` 或 `FungibleToken`。完整列表请参阅[资产对象](/cn/das-api/asset-object)。
</ResponseField>

<ResponseField name="tokenType" type="string">
  `fungible`、`nonFungible`、`regularNFT`、`compressedNFT` 或 `all`。
</ResponseField>

<ResponseField name="ownerType" type="string">
  `single`（NFT）或 `token`（同质化代币）。
</ResponseField>

<ResponseField name="compressed" type="boolean">
  匹配已压缩或未压缩的资产。
</ResponseField>

<ResponseField name="compressible" type="boolean">
  匹配可以被压缩的资产。
</ResponseField>

<ResponseField name="frozen" type="boolean">
  匹配已冻结或未冻结的资产。
</ResponseField>

<ResponseField name="burnt" type="boolean">
  匹配已销毁或仍存在的资产。
</ResponseField>

<ResponseField name="supply" type="number">
  匹配确切的供应量。
</ResponseField>

<ResponseField name="supplyMint" type="string">
  按供应 mint 匹配（base-58）。
</ResponseField>

<ResponseField name="royaltyTargetType" type="string">
  `creators`、`fanout` 或 `single`。
</ResponseField>

<ResponseField name="royaltyTarget" type="string">
  版税接收者地址（base-58）。
</ResponseField>

<ResponseField name="royaltyAmount" type="number">
  以基点计的版税。
</ResponseField>

<ResponseField name="jsonUri" type="string">
  确切的元数据 JSON URI。
</ResponseField>

<ResponseField name="name" type="string">
  资产名称。需要同时提供 `ownerAddress`。
</ResponseField>

### 逻辑

<ResponseField name="conditionType" type="string">
  `all`（默认）或 `any`。
</ResponseField>

<ResponseField name="negate" type="boolean">
  返回不匹配的资产。
</ResponseField>

### 分页与输出

<ResponseField name="page" type="number">
  页码，从 1 开始。请参阅[分页](/cn/das-api/pagination)。
</ResponseField>

<ResponseField name="limit" type="number">
  每页结果数。最大值和默认值均为 1,000。
</ResponseField>

<ResponseField name="cursor" type="string">
  来自上一次响应的游标。
</ResponseField>

<ResponseField name="before" type="string">
  返回 ID 在此 ID 之前的资产。
</ResponseField>

<ResponseField name="after" type="string">
  返回 ID 在此 ID 之后的资产。
</ResponseField>

<ResponseField name="sortBy" type="object">
  `{ "sortBy": "id" | "created" | "updated" | "recent_action" | "none", "sortDirection": "asc" | "desc" }`
</ResponseField>

<ResponseField name="options" type="object">
  [显示选项](/cn/das-api/display-options)：`showNativeBalance`（需配合 `ownerAddress`）、`showUnverifiedCollections`、`showCollectionMetadata`、`showInscription`。也可以作为 `displayOptions` 传入。
</ResponseField>

## 响应

一个列表，包含 `last_indexed_slot`、`total`、`limit`、`page` 或 `cursor`、`items`（[资产对象](/cn/das-api/asset-object)），以及使用 `showNativeBalance` 时的 `nativeBalance`。

## 代码示例

### 某个合集中仍存在的 NFT

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "searchAssets",
  "params": {
    "grouping": ["collection", "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w"],
    "burnt": false,
    "page": 1,
    "limit": 1
  }
}'
```

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "result": {
    "last_indexed_slot": 457714710,
    "total": 1,
    "limit": 1,
    "page": 1,
    "items": [
      {
        "interface": "ProgrammableNFT",
        "id": "JEGruwYE13mhX2wi2MGrPmeLiVyZtbBptmVy9vG3pXRC",
        "content": {
          "metadata": { "name": "Mad Lads #6867", "symbol": "MAD" }
        },
        "burnt": false
      }
    ]
  },
  "id": 1
}
```

### 某个钱包持有的同质化代币

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "searchAssets",
  "params": {
    "ownerAddress": "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY",
    "tokenType": "fungible",
    "page": 1,
    "limit": 100,
    "options": { "showNativeBalance": true }
  }
}'
```

### 某个钱包在一个合集中持有的压缩 NFT

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const RPC_URL = 'https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY';

const response = await fetch(RPC_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'searchAssets',
    params: {
      ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
      grouping: ['collection', 'DRiP3vrQ7LuvQtmwL74RcejviWmQ1HuuKFcJdUpYG6Di'],
      compressed: true,
      page: 1,
      limit: 1000,
    },
  }),
});
const { result } = await response.json();
console.log(`${result.items.length} compressed DRiP NFTs`);
```

## 常见错误

| 错误码 | 消息 | 解决方案 |
| - | - | - |
| -32602 | Owner address must be provided in order to search assets by name | 按 `name` 筛选时添加 `ownerAddress` |
| -32602 | Validation Error: Invalid pubkey ... | 检查每个地址筛选条件是否为有效的 base-58 |
| -32602 | unknown field | 检查参数名称；筛选条件使用 camelCase |
| -32602 | Pagination Sorting Error | 游标和范围需要 `sortBy: "id"`；其他排序方式请使用 `page` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.