> ## 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.

# getAssetWithProof

> 在 OrbitFlare 上使用 getAssetWithProof，通过单个 DAS 请求获取 Solana 压缩 NFT 及其 Merkle 证明。

## 概述

构建 Bubblegum 转移、销毁或委托指令需要来自两处的数据：资产本身（所有者、委托人、数据哈希、创作者哈希、叶子索引）及其 Merkle 证明。`getAssetWithProof` 在一次往返中同时返回两者。

该方法是 OrbitFlare 新增的方法。你仍然可以分别调用 [getAsset](/cn/das-api/methods/getAsset) 和 [getAssetProof](/cn/das-api/methods/getAssetProof)。

## 参数

<ResponseField name="id" type="string" required>
  压缩资产 ID（base-58）。
</ResponseField>

<ResponseField name="options" type="object">
  资产的[显示选项](/cn/das-api/display-options)：`showUnverifiedCollections`、`showCollectionMetadata`、`showInscription`。也可以作为 `displayOptions` 传入。
</ResponseField>

## 响应

<ResponseField name="result" type="object">
  <Expandable title="result 字段">
    <ResponseField name="asset" type="object">
      [资产对象](/cn/das-api/asset-object)。
    </ResponseField>

    <ResponseField name="proof" type="object">
      Merkle 证明，字段与 [getAssetProof](/cn/das-api/methods/getAssetProof) 相同。
    </ResponseField>
  </Expandable>
</ResponseField>

## 代码示例

### 请求

```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": "getAssetWithProof",
  "params": {
    "id": "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU"
  }
}'
```

### 响应

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "result": {
    "asset": {
      "interface": "V1_NFT",
      "id": "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU",
      "compression": {
        "eligible": false,
        "compressed": true,
        "data_hash": "6TuHoKagPg1Vqz92K5fiUNJtSC7wXHXSQfadLPnXsP8s",
        "creator_hash": "EuiqSYWYf6KnUcEmorrTrGQovPKF9a1wSVJAk7bfLgnR",
        "asset_hash": "CcMhrzXFkjyLwZdijjRibgSYw4tUzXYALoCxwms4aMFH",
        "tree": "E7fYCRWkNykc8HNZvEMRj5GuNYSwJ3WjA6HuLsh3YHvL",
        "seq": 627605,
        "leaf_id": 622994
      },
      "ownership": {
        "frozen": false,
        "delegated": false,
        "delegate": null,
        "ownership_model": "single",
        "owner": "5MRNQW3NxNes1EDnxUhqyXwffseQBLpdu6QJF8G4MdN9"
      }
    },
    "proof": {
      "root": "3wxyaNRvzuZqDd9jtqthCu87spdKuhcpaKVzP1msGyHW",
      "proof": [
        "8mjbWMPrBwYJeEmQbeYLR7mscS4umW4U3kxibuH8hcY1",
        "DV31TLc5BXCnCQMaQ9H6empbG9i69w4AWkjR5RPiyXr8",
        "G6f1pEKetujNm6JXQxD47eBudxLV1irR1U5atpAXBb4q"
      ],
      "node_index": 1671570,
      "leaf": "CcMhrzXFkjyLwZdijjRibgSYw4tUzXYALoCxwms4aMFH",
      "tree_id": "E7fYCRWkNykc8HNZvEMRj5GuNYSwJ3WjA6HuLsh3YHvL"
    }
  },
  "id": 1
}
```

此处的资产和证明已做精简。完整示例请参阅 [getAsset](/cn/das-api/methods/getAsset) 和 [getAssetProof](/cn/das-api/methods/getAssetProof)。

### TypeScript

收集 Bubblegum 转移所需的字段：

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

async function getTransferInputs(assetId: string) {
  const response = await fetch(RPC_URL, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: 1,
      method: 'getAssetWithProof',
      params: { id: assetId },
    }),
  });
  const { result, error } = await response.json();
  if (error) throw new Error(error.message);

  const { asset, proof } = result;
  return {
    merkleTree: proof.tree_id,
    root: proof.root,
    proof: proof.proof,
    leafOwner: asset.ownership.owner,
    leafDelegate: asset.ownership.delegate ?? asset.ownership.owner,
    dataHash: asset.compression.data_hash,
    creatorHash: asset.compression.creator_hash,
    nonce: asset.compression.leaf_id,
    index: asset.compression.leaf_id,
  };
}
```

## 常见错误

| 错误码 | 消息 | 解决方案 |
| - | - | - |
| -32602 | Pubkey Validation Err: ... is invalid | 传入有效的 base-58 资产 ID |
| -32000 | Asset Proof Not Found | 该资产未被压缩，或尚未被索引 |


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