External Plugins

AppData Plugin

What is an AppData Plugin?

The AppData external plugin stores and contains arbitrary data that can be written to by the dataAuthority. Note this is different then the overall plugin authority stored in the ExternalRegistryRecord as it cannot update/revoke authority or change other metadata for the plugin.

Think of AppData as like a partition data area of an Asset that only a certain authority can change and write to.

This is useful for 3rd party sites/apps to store data needed to execute certain functionality within their product/app.

Works With

MPL Core Asset
MPL Core Collection*

* MPL Core Collections can also work with the LinkedAppData Plugin.

What is a LinkedAppData Plugin?

The LinkedAppData plugin is built for Collections. It allows you to add a single plugin adapter on the collection which will allow you to write to any Asset in the collection.

Arguments

ArgValue
dataAuthorityPluginAuthority
schemaExternalPluginAdapterSchema

dataAuthority

AttributeList

const dataAuthority = {
  type: 'Address',
  address: publicKey('11111111111111111111111111111111'),
}

schema

The schema determines the type of data that is being stored within the AppData plugin. All schemas will be indexed by DAS.

ArgDAS SupportedStored as
Binary (Raw Data)base64
Jsonjson
MsgPackjson

When indexing the data if there was an error reading the json or msgpack schema then it will be saved as binary.

Writing data to the AppData plugin

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

// Chose from Binary, Json or MsgPack
const schema = ExternalPluginAdapterSchema.Json

Adding the AppData Plugin to an Asset

Adding a Attribute Plugin to an MPL Core Asset

import { publicKey } from '@metaplex-foundation/umi'
import { addPlugin, ExternalPluginAdapterSchema } from '@metaplex-foundation/mpl-core'

const assetSigner = generateSigner(umi);
const dataAuthority = publicKey('11111111111111111111111111111111')

await create(umi, {
  asset: asset.publicKey,
  name: "My Asset",
  uri: "https://example.com/my-assets.json"
  plugins: [
        {
            type: 'AppData',
            dataAuthority,
            schema: ExternalPluginAdapterSchema.Json,
        },
    ],
}).sendAndConfirm(umi)

// Alternatively you could add the plugin to an existing Asset

await addPlugin(umi, {
  asset,
  plugin: {
        type: 'AppData',
        dataAuthority,
        schema: ExternalPluginAdapterSchema.Json,
    },
})

Writing Data to the AppData plugin.

Only the dataAuthority address can write data to the AppData plugin.

To write data to the AppData plugin we will use a writeData() helper which takes the following args.

ArgValue
key{ type: string, dataAuthority: publicKey}
authoritysigner
datadata in the format you wish to store
assetpublicKey

Writing data to the AppData plugin

await writeData(umi, {
  key: {
    type: 'AppData',
    dataAuthority,
  },
  authority: dataAuthoritySigner,
  data: Uint8Array.from(Buffer.from(data)),
  asset: asset.publicKey,
}).sendAndConfirm(umi)
Previous
Oracle Plugin