Skip to main content

Metadata

Represents the metadata for an NFT, including traits and associated data.

Index

Constructors

constructor

  • new Metadata(params: { banner?: string; description?: string; image: string; name: string; plugins?: MetadataPlugin[] }): Metadata
  • Creates a new Metadata instance.


    Parameters

    • params: { banner?: string; description?: string; image: string; name: string; plugins?: MetadataPlugin[] }

      The parameters for the metadata, including name, image, description, banner, and plugins.

      • optionalbanner: string
      • optionaldescription: string
      • image: string
      • name: string
      • optionalplugins: MetadataPlugin[]

    Returns Metadata

Properties

optionalbanner

banner?: string

Optional banner image for the NFT.

optionaldescription

description?: string

Optional description of the NFT.

image

image: string

The image associated with the NFT.

readonlymap

The underlying map storing the metadata key-value pairs.

readonlyname

name: string

The name of the NFT.

plugins

plugins: MetadataPlugin[]

Array of metadata plugins used for custom traits.

traits

traits: {} = {}

Object containing the traits of the NFT.


Type declaration

  • [key string]: { isPrivate: boolean; type: string; value: string | Field | Metadata | MetadataTree | unknown }

Methods

addTrait

  • addTrait(params: { isPrivate?: boolean; key: string; type: string; value: unknown }): { key: Field; value: MetadataValue }
  • Adds a trait to the metadata.


    Parameters

    • params: { isPrivate?: boolean; key: string; type: string; value: unknown }

      The parameters including key, type, value, and isPrivate.

      • optionalisPrivate: boolean
      • key: string
      • type: string
      • value: unknown

    Returns { key: Field; value: MetadataValue }

    An object containing the key and the metadata value.

toJSON

  • toJSON(includePrivateTraits?: boolean): { banner?: string; description?: string; image: string; metadataRoot: string; name: string; traits: { isPrivate?: boolean; key: string; type: string; value: string | object }[] }
  • Converts the metadata to a JSON representation.


    Parameters

    • includePrivateTraits: boolean = false

      Whether to include private traits.

    Returns { banner?: string; description?: string; image: string; metadataRoot: string; name: string; traits: { isPrivate?: boolean; key: string; type: string; value: string | object }[] }

    The JSON representation of the metadata.

    • optionalbanner?: string
    • optionaldescription?: string
    • image: string
    • metadataRoot: string
    • name: string
    • traits: { isPrivate?: boolean; key: string; type: string; value: string | object }[]

staticfromJSON

  • fromJSON(params: { checkRoot?: boolean; json: { banner?: string; description?: string; image: string; metadataRoot: string; name: string; traits: { isPrivate?: boolean; key: string; type: string; value: string | object }[] }; plugins?: MetadataPlugin[] }): Metadata
  • Constructs a Metadata instance from JSON data.


    Parameters

    • params: { checkRoot?: boolean; json: { banner?: string; description?: string; image: string; metadataRoot: string; name: string; traits: { isPrivate?: boolean; key: string; type: string; value: string | object }[] }; plugins?: MetadataPlugin[] }

      The parameters including json data, checkRoot flag, and plugins.

      • optionalcheckRoot: boolean
      • json: { banner?: string; description?: string; image: string; metadataRoot: string; name: string; traits: { isPrivate?: boolean; key: string; type: string; value: string | object }[] }
      • optionalplugins: MetadataPlugin[]

    Returns Metadata

    A new Metadata instance.