概述
getAsset 按 ID 返回单个资产:元数据、所有权、版税、创作者、合集、压缩状态和代币详情,全部在一次调用中返回。它适用于 DAS API 索引的所有资产类型。
参数
string
必填
资产 ID(base-58)。对于基于代币的资产,请使用 mint 地址。
object
显示选项:
showUnverifiedCollections、showCollectionMetadata、showInscription。也可以作为 displayOptions 传入。响应
一个资产对象。代码示例
请求
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": "getAsset",
"params": {
"id": "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU"
}
}'
响应
来自 DRiP 合集的一个压缩 NFT:{
"jsonrpc": "2.0",
"result": {
"last_indexed_slot": 457714576,
"interface": "V1_NFT",
"id": "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://arweave.net/ymSDHwAqb3hnNKBid03WBUqY1Svj5Hzr0fdAYGvZBKA",
"files": [
{
"uri": "https://arweave.net/2dfCrqZmpUTPEaPHuI9QUdZocNa-JYkG-3nBKycF-AM?ext=jpg",
"mime": "image/jpeg"
}
],
"metadata": {
"attributes": [
{ "value": "3", "trait_type": "Season" },
{ "value": "Common", "trait_type": "Rarity" }
],
"description": "Combination between Angkor Wat photography with microscopic creation as the sky.",
"name": "Aurora borealis",
"symbol": "",
"token_standard": "NonFungible"
},
"links": {
"external_url": "https://drip.haus/showcase",
"image": "https://arweave.net/2dfCrqZmpUTPEaPHuI9QUdZocNa-JYkG-3nBKycF-AM?ext=jpg"
},
"category": "image"
},
"authorities": [
{ "address": "5warkgXZEtubURnNHN1BcpgSBja31zeSvWudeXQEPpTr", "scopes": ["full"] }
],
"compression": {
"eligible": false,
"compressed": true,
"data_hash": "6TuHoKagPg1Vqz92K5fiUNJtSC7wXHXSQfadLPnXsP8s",
"creator_hash": "EuiqSYWYf6KnUcEmorrTrGQovPKF9a1wSVJAk7bfLgnR",
"asset_hash": "CcMhrzXFkjyLwZdijjRibgSYw4tUzXYALoCxwms4aMFH",
"tree": "E7fYCRWkNykc8HNZvEMRj5GuNYSwJ3WjA6HuLsh3YHvL",
"seq": 627605,
"leaf_id": 622994
},
"grouping": [
{ "group_key": "collection", "group_value": "DRiP3vrQ7LuvQtmwL74RcejviWmQ1HuuKFcJdUpYG6Di" }
],
"royalty": {
"royalty_model": "creators",
"target": null,
"percent": 0.015,
"basis_points": 150,
"primary_sale_happened": false,
"locked": false
},
"creators": [
{ "address": "DRiPPP2LytGjNZ5fVpdZS7Xi1oANSY3Df1gSxvUKpzny", "share": 0, "verified": true },
{ "address": "WoMbXFtdfH8crq2Zi7bQhfGx2Gv8EN4saP13gcdUGog", "share": 100, "verified": false }
],
"ownership": {
"frozen": false,
"delegated": false,
"delegate": null,
"ownership_model": "single",
"owner": "5MRNQW3NxNes1EDnxUhqyXwffseQBLpdu6QJF8G4MdN9"
},
"supply": {
"print_max_supply": 0,
"print_current_supply": 0,
"edition_nonce": null
},
"mutable": true,
"burnt": false
},
"id": 1
}
TypeScript
const RPC_URL = 'https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY';
async function getAsset(id: string) {
const response = await fetch(RPC_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'getAsset',
params: { id },
}),
});
const { result, error } = await response.json();
if (error) throw new Error(error.message);
return result;
}
const asset = await getAsset('JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU');
console.log(asset.content.metadata.name, asset.ownership.owner);
常见错误
| 错误码 | 消息 | 解决方案 |
|---|---|---|
| -32602 | Pubkey Validation Err: … is invalid | 传入有效的 base-58 资产 ID |
| -32602 | unknown field | 检查参数名称;DAS 参数使用 camelCase |
| -32000 | Asset Not Found | 该 ID 不是资产,或尚未被索引 |
相关方法
- getAssetBatch:在一次调用中获取最多 1,000 个资产
- getAssetWithProof:同时获取压缩资产及其证明