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

# getAssetProof

> 在 OrbitFlare 上使用 DAS getAssetProof，获取转移、销毁或更新 Solana 压缩 NFT 所需的 Merkle 证明。

## 概述

压缩 NFT 以叶子的形式存在于并发 Merkle 树中，而不是存放在各自的账户里。要转移、销毁、委托或更新一个压缩 NFT，交易必须证明该叶子存在于树中。`getAssetProof` 返回这一证明：当前根、从叶子到根的兄弟节点哈希，以及叶子哈希。

<Tip>
  如果你还需要资产本身（用于获取所有者、委托人和哈希），请使用 [getAssetWithProof](/cn/das-api/methods/getAssetWithProof) 在一次调用中同时获取两者。
</Tip>

## 参数

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

## 响应

<ResponseField name="result" type="object">
  <Expandable title="证明字段">
    <ResponseField name="root" type="string">
      Merkle 树的当前根。
    </ResponseField>

    <ResponseField name="proof" type="string[]">
      从叶子到根的兄弟节点哈希。
    </ResponseField>

    <ResponseField name="node_index" type="number">
      叶子节点在树中的索引。
    </ResponseField>

    <ResponseField name="leaf" type="string">
      叶子的哈希。
    </ResponseField>

    <ResponseField name="tree_id" type="string">
      Merkle 树地址。
    </ResponseField>

    <ResponseField name="last_indexed_slot" type="number">
      索引已处理的最新 slot。
    </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": "getAssetProof",
  "params": {
    "id": "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU"
  }
}'
```

### 响应

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "result": {
    "last_indexed_slot": 457714576,
    "root": "3wxyaNRvzuZqDd9jtqthCu87spdKuhcpaKVzP1msGyHW",
    "proof": [
      "8mjbWMPrBwYJeEmQbeYLR7mscS4umW4U3kxibuH8hcY1",
      "DV31TLc5BXCnCQMaQ9H6empbG9i69w4AWkjR5RPiyXr8",
      "G6f1pEKetujNm6JXQxD47eBudxLV1irR1U5atpAXBb4q",
      "FbztVPKvuxh5SKvgwnnfahS1cX1pNCkDwdGWXjiS6uMr",
      "4o3C635ciZfE3DhDbJd3SUi4NziqsTe4qUMYpUycEPnD",
      "7wYFA3aSJzJiUQeLX8W3z8n6kj38MvXjS4THiR8EqXaX",
      "ySuYMGpCfwSaPCSekQ7GqzPwK2tNFQRiXzpMBk87y2G",
      "4cEUgjcHgRLHaTb8W3b8zepKd5mEM2YSjUaE1SUVtp9E",
      "AUaRHd35EJPV6WVzgfDease3DUQzYRGnDM72kPNJMxxY",
      "BXmjgYrVGcypzZToQkC4YzAKTfKJDkUbwR5zzLXzYZyv",
      "H2Z3JbU8P1hyNKZErvmhfJVwsQBbQuNrJqXkZb6hL1Ct",
      "8mRjuEbofX63HUHfRrScqKMWuTYJsjeGPDAz7tWPqP45",
      "4BCzbM5wTzy3nCNQ7Sd8px1w4pBwse2VZksZVeVgGN5D",
      "6d4JjgVgErnnBLjzLSQcuAJEc9fUhTbDNRXihjuhPpJ3",
      "8AhhfYKmRs8srSsp9BeWTrjkTUrXh5UDu17C1ApueuD4",
      "6eQoNu6H4dDsRgdJFFMKAFuAiYDRLDwrza52gn9W8pX2",
      "AWnzWhtFyRdQTVmd3NwNNXEJuSzcu33L73RXJgukaEnM",
      "BViAqVspYKdhqYKqVpntUmspSBSWqibm6LjWdvP2F2Vj",
      "BMkvaTguMUzPD4SEr2EQ2j15mrnucrKnUzrVHyMpDbw2",
      "EdGUXNZE4FDSYtKY7SDYAam2a7atkGAmezhGFnfauiA9"
    ],
    "node_index": 1671570,
    "leaf": "CcMhrzXFkjyLwZdijjRibgSYw4tUzXYALoCxwms4aMFH",
    "tree_id": "E7fYCRWkNykc8HNZvEMRj5GuNYSwJ3WjA6HuLsh3YHvL"
  },
  "id": 1
}
```

### TypeScript

将证明作为剩余账户传给 Bubblegum 指令：

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
import { PublicKey, AccountMeta } from '@solana/web3.js';

const RPC_URL = 'https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY';

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

  // Nodes stored in the tree's canopy are already on chain and can be left out.
  const proofPath: AccountMeta[] = result.proof
    .slice(0, result.proof.length - canopyDepth)
    .map((node: string) => ({ pubkey: new PublicKey(node), isSigner: false, isWritable: false }));

  return { root: new PublicKey(result.root), proofPath };
}
```

## 注意事项

* 证明仅在树发生变化之前有效。请在构建交易之前立即获取证明，如果交易因根不匹配而失败，请重新获取。
* 带有 canopy 的树会将顶部若干层存储在链上，因此你可以从 `proof` 的末尾去掉相应数量的节点，以节省交易空间。

## 常见错误

| 错误码 | 消息 | 解决方案 |
| - | - | - |
| -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.