Features

Fetching Assets

Fetch a single asset

To fetch a single Asset the following function can be used:

Fetch a single asset

import { fetchAssetV1 } from '@metaplex-foundation/mpl-core'

const asset = await fetchAssetV1(umi, assetAddress.publicKey)

console.log(asset)

Fetch multiple Assets

Multiple Assets can either be fetched using a getProgramAccounts (GPA) call, which can be quite expensive and slow RPC wise, or using the Digital Asset Standard API, which is faster but requires specific RPC providers.

GPA fetch assets by owner

fetch assets by owner

import { publicKey } from '@metaplex-foundation/umi'
import { getAssetV1GpaBuilder, Key } from '@metaplex-foundation/mpl-core'

const owner = publicKey('11111111111111111111111111111111')

const assetsByOwner = await getAssetV1GpaBuilder(umi)
  .whereField('key', Key.AssetV1)
  .whereField('owner', owner)
  .getDeserialized()

console.log(assetsByOwner)

GPA fetch assets by collection

GPA fetch assets by collection

import { publicKey } from '@metaplex-foundation/umi'
import {
  Key,
  getAssetV1GpaBuilder,
  updateAuthority,
} from '@metaplex-foundation/mpl-core'

const collection = publicKey('11111111111111111111111111111111')

const assetsByCollection = await getAssetV1GpaBuilder(umi)
  .whereField('key', Key.AssetV1)
  .whereField('updateAuthority', updateAuthority('Collection', [collection]))
  .getDeserialized()

console.log(assetsByCollection)

DAS - Digital Asset Standard API

DAS SUPPORT IS COMING SOON!

If you use a DAS enabled RPC you'll be able to take advantage of indexed Assets for lighting fast fetches and data retrieval.

DAS will index everything from metadata, off chain metadata, collection data, plugins (including Attributes), and more. To learn more about the Metaplex DAS API you can click here.

Below is an example of returned data from fetching a MPL Core Asset with DAS.

FetchAsset Example

{
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "authorities": [
      {
        "address": "Gi47RpRmg3wGsRRzFvcmyXHkELHznpx6DxEELGWBRWoC",
        "scopes": ["full"]
      }
    ],
    "burnt": false,
    "compression": {
      "asset_hash": "",
      "compressed": false,
      "creator_hash": "",
      "data_hash": "",
      "eligible": false,
      "leaf_id": 0,
      "seq": 0,
      "tree": ""
    },
    "content": {
      "$schema": "https://schema.metaplex.com/nft1.0.json",
      "files": [],
      "json_uri": "https://example.com/asset",
      "links": {},
      "metadata": {
        "name": "Test Asset",
        "symbol": ""
      }
    },
    "creators": [],
    "grouping": [
      {
        "group_key": "collection",
        "group_value": "8MPNmg4nyMGKdStSxbo2r2aoQGWz1pdjtYnQEt1kA2V7"
      }
    ],
    "id": "99A5ZcoaRSTGRigMpeu1u4wdgQsv6NgTDs5DR2Ug9TCQ",
    "interface": "MplCore",
    "mutable": true,
    "ownership": {
      "delegate": null,
      "delegated": false,
      "frozen": false,
      "owner": "Gi47RpRmg3wGsRRzFvcmyXHkELHznpx6DxEELGWBRWoC",
      "ownership_model": "single"
    },
    "plugins": {
      "FreezeDelegate": {
        "authority": {
          "Pubkey": {
            "address": "Gi47RpRmg3wGsRRzFvcmyXHkELHznpx6DxEELGWBRWoC"
          }
        },
        "data": {
          "frozen": false
        },
        "index": 0,
        "offset": 119
      }
    },
    "royalty": {
      "basis_points": 0,
      "locked": false,
      "percent": 0,
      "primary_sale_happened": false,
      "royalty_model": "creators",
      "target": null
    },
    "supply": null,
    "unknown_plugins": [
      {
        "authority": {
          "Pubkey": {
            "address": "Gi47RpRmg3wGsRRzFvcmyXHkELHznpx6DxEELGWBRWoC"
          }
        },
        "data": "CQA=",
        "index": 1,
        "offset": 121,
        "type": 9
      }
    ]
  }
}
Previous
Creating Assets