Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metaplex-foundation/digital-asset-standard-api

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metaplex-foundation/digital-asset-standard-api

Open-source specification for interacting with digital assets on Solana

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

Metaplex Digital Asset Standard API

(a.k.a. Metaplex Read API)

Open-source specification for interacting with digital assets on Solana.

Metaplex Digital Asset Standard

Overview

The state data of uncompressed NFTs is all stored in on-chain accounts. This is expensive at scale. Compressed NFTs save space by encoding the state data into an on-chain Merkle tree. The detailed account data is not stored on-chain, but in data stores managed by RPC providers. The Metaplex Digital Asset Standard (DAS) API represents a unified interface for interacting with digital assets on Solana, supporting both standard (Token Metadata) and compressed (Bubblegum) assets.

The API defines a set of methods that RPCs implement in order to provide asset data. In the majority of cases, the data is indexed using Metaplex Digital Asset RPC infrastructure.

Getting Started

The @metaplex-foundation/digital-asset-standard-api package can be use to interact with Metaplex DAS API.

  1. First, if you are not already using Umi, follow these instructions to install the Umi framework.
  2. Next, install this library using the package manager of your choice.
    npm install @metaplex-foundation/digital-asset-standard-api
    
  3. Finally, register the library with your Umi instance.
    import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';
    umi.use(dasApi());
    

Examples are provided here and you can learn more about this library's API by reading its generated TypeDoc documentation.

Note The plugin can be used with any RPC that supports the Metaplex DAS API specification. You might need to contact your RPC provider to "enable" the Metaplex DAS API on your endpoint.

Working with mpl-core

Core assets and collections are also indexed by DAS. It is recommended to use this package in conjunction with the mpl-core-das if you are working with Core assets.

Methods

💡 You can test each method of the API using the OpenRPC playground.

NameDescriptionExample
getAssetReturn the metadata information of a compressed/standard asset
getAssetProofReturn the merkle tree proof information for a compressed asset
getAssetsByOwnerReturn the list of assets given an owner address
getAssetsByAuthorityReturn the list of assets given an authority address
getAssetsByCreatorReturn the list of assets given a creator address
getAssetsByGroupReturn the list of assets given a group (key, value) pair
searchAssetsReturn the list of assets given a search criteria

Examples

⚠️ You should replace the <ENDPOINT> with the RPC endpoint to use.

📌 getAsset
parameters
NameRequiredDescription
idThe id of the asset.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());
const assetId = publicKey('8TrvJBRa6Pzb9BDadqroHhWTHxaxK8Ws8r91oZ2jxaVV');

const asset = await umi.rpc.getAsset(assetId);
console.log(asset);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "getAsset",
    "params": [
      "8vw7tdLGE3FBjaetsJrZAarwsbc8UESsegiLyvWXxs5A"
    ],
    "id": 0
}'
📌 getAssetProof
parameters
NameRequiredDescription
idThe id of the asset.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());
const assetId = publicKey('Ez6ezCMkRaUkWS5v6WVcP7uuCWiKadr3W2dHFkoZmteW');

const proof = await umi.rpc.getAssetProof(assetId);
console.log(proof);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "getAssetProof",
    "params": [
      "Ez6ezCMkRaUkWS5v6WVcP7uuCWiKadr3W2dHFkoZmteW"
    ],
    "id": 0
}'
📌 getAssetsByAuthority
parameters
NameRequiredDescription
authorityAddressThe address of the authority of the assets.
sortBySorting criteria. This is specified as an object { sortBy: <value>, sortDirection: <vlaue> }, where sortBy is one of ["created", "updated", "recentAction", "none"] and sortDirection is one of ["asc", "desc"]
limitThe maximum number of assets to retrieve.
pageThe index of the "page" to retrieve.
beforeRetrieve assets before the specified ID.
afterRetrieve assets after the specified ID.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());
const authority = publicKey('mRdta4rc2RtsxEUDYuvKLamMZAdW6qHcwuq866Skxxv');

const assets = await umi.rpc.getAssetsByAuthority({ authority });
console.log(assets.items.length > 0);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "getAssetsByAuthority",
    "params": {
        "authorityAddress": "mRdta4rc2RtsxEUDYuvKLamMZAdW6qHcwuq866Skxxv",
        "page": 1
    },
    "id": 0
}'
📌 getAssetsByCreator
parameters
NameRequiredDescription
creatorAddressThe address of the creator of the assets.
onlyVerifiedIndicates whether to retrieve only verified assets or not.
sortBySorting criteria. This is specified as an object { sortBy: <value>, sortDirection: <vlaue> }, where sortBy is one of ["created", "updated", "recentAction", "none"] and sortDirection is one of ["asc", "desc"]
limitThe maximum number of assets to retrieve.
pageThe index of the "page" to retrieve.
beforeRetrieve assets before the specified ID.
afterRetrieve assets after the specified ID.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());
const creator = publicKey('D3XrkNZz6wx6cofot7Zohsf2KSsu2ArngNk8VqU9cTY3');

const assets = await umi.rpc.getAssetsByCreator({
    creator,
    onlyVerified: false,
    limit: 10,
});
console.log(assets.items.length > 0);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "getAssetsByCreator",
    "params": {
        "creatorAddress": "D3XrkNZz6wx6cofot7Zohsf2KSsu2ArngNk8VqU9cTY3",
        "onlyVerified": false,
        "limit": 10,
        "page": 1
    },
    "id": 0
}'
📌 getAssetsByGroup
parameters
NameRequiredDescription
groupKeyThe key of the group (e.g., "collection").
groupValueThe value of the group.
sortBySorting criteria. This is specified as an object { sortBy: <value>, sortDirection: <vlaue> }, where sortBy is one of ["created", "updated", "recentAction", "none"] and sortDirection is one of ["asc", "desc"]
limitThe maximum number of assets to retrieve.
pageThe index of the "page" to retrieve.
beforeRetrieve assets before the specified ID.
afterRetrieve assets after the specified ID.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());

const assets = await umi.rpc.getAssetsByGroup({
    groupKey: 'collection',
    groupValue: 'J2ZfLdQsaZ3GCmbucJef3cPnPwGcgjDW1SSYtMdq3L9p',
});
console.log(assets.items.length > 0);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "getAssetsByGroup",
    "params": {
        "groupKey": "collection",
        "groupValue": "J2ZfLdQsaZ3GCmbucJef3cPnPwGcgjDW1SSYtMdq3L9p",
        "page": 1
    },
    "id": 0
}'
📌 getAssetsByOwner
parameters
NameRequiredDescription
ownerAddressThe address of the owner of the assets.
sortBySorting criteria. This is specified as an object { sortBy: <value>, sortDirection: <vlaue> }, where sortBy is one of ["created", "updated", "recentAction", "none"] and sortDirection is one of ["asc", "desc"]
limitThe maximum number of assets to retrieve.
pageThe index of the "page" to retrieve.
beforeRetrieve assets before the specified ID.
afterRetrieve assets after the specified ID.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());
const owner = publicKey('N4f6zftYsuu4yT7icsjLwh4i6pB1zvvKbseHj2NmSQw');

const assets = await umi.rpc.getAssetsByOwner({
    owner,
    limit: 10
});
console.log(assets.items.length > 0);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "getAssetsByOwner",
    "params": {
        "ownerAddress": "N4f6zftYsuu4yT7icsjLwh4i6pB1zvvKbseHj2NmSQw",
        "limit": 10,
        "page": 1
    },
    "id": 0
}'
📌 searchAssets
parameters
NameRequiredDescription
negateIndicates whether the search criteria should be inverted or not.
conditionTypeIndicates whether to retrieve all ("all") or any ("any") asset that matches the search criteria.
interfaceThe interface value (one of ["V1_NFT", "V1_PRINT" "LEGACY_NFT", "V2_NFT", "FungibleAsset", "Custom", "Identity", "Executable"]).
ownerAddressThe address of the owner.
ownerTypeType of ownership ["single", "token"].
creatorAddressThe address of the creator.
creatorVerifiedIndicates whether the creator must be verified or not.
authorityAddressThe address of the authority.
groupingThe grouping ["key", "value"] pair.
delegateAddressThe address of the delegate.
frozenIndicates whether the asset is frozen or not.
supplyThe supply of the asset.
supplyMintThe address of the supply mint.
compressedIndicates whether the asset is compressed or not.
compressibleIndicates whether the asset is compressible or not.
royaltyTargetTypeType of royalty ["creators", "fanout", "single"].
royaltyTargetThe target address for royalties.
royaltyAmountThe royalties amount.
burntIndicates whether the asset is burnt or not.
sortBySorting criteria. This is specified as an object { sortBy: <value>, sortDirection: <vlaue> }, where sortBy is one of ["created", "updated", "recentAction", "none"] and sortDirection is one of ["asc", "desc"].
limitThe maximum number of assets to retrieve.
pageThe index of the "page" to retrieve.
beforeRetrieve assets before the specified ID.
afterRetrieve assets after the specified ID.
jsonUriThe value for the JSON URI.
typescript
import { publicKey } from '@metaplex-foundation/umi';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';

const umi = createUmi('<ENDPOINT>').use(dasApi());

const assets = await umi.rpc.searchAssets({
    owner: publicKey('N4f6zftYsuu4yT7icsjLwh4i6pB1zvvKbseHj2NmSQw'),
    jsonUri: 'https://arweave.net/c9aGs5fOk7gD4wWnSvmzeqgtfxAGRgtI1jYzvl8-IVs/chiaki-violet-azure-common.json',
});
console.log(assets.items.length == 1);
curl
curl --request POST --url "<ENDPOINT>" --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "method": "searchAssets",
    "params": {
        "ownerAddress": "N4f6zftYsuu4yT7icsjLwh4i6pB1zvvKbseHj2NmSQw",
        "jsonUri": "https://arweave.net/c9aGs5fOk7gD4wWnSvmzeqgtfxAGRgtI1jYzvl8-IVs/chiaki-violet-azure-common.json",
        "page": 1
    },
    "id": 0
}'

Keywords

FAQs

Package last updated on 04 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc