# Convert Metadata

## `convertMetadata()`

Metadata JSON is converted to the latest version according to the version schema

## Method parameters

| Variable        | Type              | Description                               |
| --------------- | ----------------- | ----------------------------------------- |
| `metadataBatch` | `MetadataBatch[]` | Refer MetadataBatch for all possible data |

### MetadataBatch

| Variable          | Type            | Description                                                                                                                                                                                                                                  |
| ----------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata`        | `MetadataBatch` | Refer to the [Startrail Registry (SRR) data schema](/metadata-schema/startrail-registry-srr.md) for all possible data                                                                                                                        |
| `tokenId`         | `string`        | Startrail Registry Record Token ID                                                                                                                                                                                                           |
| `externalUrl`     | `string`        | External reference URL used in the metadata externalUrl field. Refer to the [Startrail Registry (SRR) data schema](/metadata-schema/startrail-registry-srr.md) for details.                                                                  |
| `artistName`      | `string`        | The artist's name used in the metadata description field. If the SRR already exists, we use the registered artist name instead. Refer to the [Startrail Registry (SRR) data schema](/metadata-schema/startrail-registry-srr.md) for details. |
| `issuerName`      | `string`        | The user's name used in the metadata description field. If the SRR already exists, we use the registered user name instead. Refer to the [Startrail Registry (SRR) data schema](/metadata-schema/startrail-registry-srr.md) for details.     |
| `contractAddress` | `string`        | The address of collection contract associated to the SRR                                                                                                                                                                                     |

### Parameters Example

```
await sdk.convertMetadata(
  {
    "metadataBatch": [
      {
        "metadata": {
          "$schema": "https://api.startrail.io/api/v1/schema/registry-record-metadata.v1.1.schema.json",
          "$schemaIntegrity": "sha256-fff288406b907ee6472585388bf519573628e45592be368f128b5b1e37a947c9",
          "startbahnCertICTagUIDs": [
            "1234567890abcdef"
          ],
          "title": {
            "en": "A title",
            "ja": "タイトル",
            "zh": "一个标题"
          },
          "size": {
            "width": 200,
            "height": 400,
            "depth": 12.4,
            "unit": "pixel",
            "flexibleDescription": {
              "en": "flexibleDescription comes here",
              "ja": "自由だーーー"
            }
          },
          "medium": {
            "en": "Oil on canvas",
            "ja": "キャンバスに油彩",
            "zh": "布面油画"
          },
          "edition": {
            "uniqueness": "unique work",
            "proofType": "ED",
            "number": 1,
            "totalNumber": 3,
            "note": {
              "en": "some extra notes in 1 or more languages"
            }
          },
          "contractTerms": {
            "royaltyRate": 15.7,
            "fileURL": "https://startrail.io/whitepaper/startrail_wp_en_v1.1.pdf"
          },
          "note": {
            "en": "note",
            "zh": "注意"
          },
          "thumbnailURL": "https://storage.googleapis.com/opensea-prod.appspot.com/puffs/3.png",
          "yearOfCreation": {
            "en": "around 2010-2020",
            "ja": "2010年から2020年頃"
          },
          "isDigital": true,
          "digitalDataHash": "sha256-247e4b904322a1dd0b148cd77e8627ec7d391251380880ab4621726ecb945ef5"
        },
        "artistName": "string",
        "externalUrl": "https://sample.com",
        "issuerName": "string",
        "tokenId": "string",
        "contractAddress": "string"
      }
    ]
  }
)

```

## Returns

`Promise` will be returned which resolves with a `Response` object upon a successful confirmation. `false` will be returned when user flow is cancelled in such a case that a user closes the popup modal.

If the confirmation fails, the `Promise` will resolve with an {error} object that describes the failure.

`Promise<Response[] | false>`

### Response

| Variable      | Type        | Description                                                                                                                               |
| ------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata`    | `object`    | Converted metadata. Refer to the [Startrail Registry (SRR) data schema](/metadata-schema/startrail-registry-srr.md) for all possible data |
| `isConverted` | `TxDetails` | True is returned if metadata is converted                                                                                                 |
| `message`     | `TxDetails` | Error message is returned if any.                                                                                                         |

### Error

Custom `Error` objects. Refer to the [Error Catalogue](/startrail-sdk-js/errors.md) for possible data.

### Response Example

```
{
  metadata: [
    {
      "$schema": "ipfs://bafkreif77ionobe56gawqnplet46x3sjfinx3krm4reldzn7v6c2nfrmy4",
      "startbahnCertICTagUIDs": [
        "1234567890abcdef"
      ],
      "chipUIDs": [
        "1234567890abcdef"
      ],
      "title": {
        "en": "A title",
        "ja": "タイトル",
        "zh": "一个标题"
      },
      "size": {
        "width": 200.0,
        "height": 400.0,
        "depth": 12.4,
        "unit": "pixel",
        "flexibleDescription": {
          "en": "flexibleDescription comes here",
          "ja": "自由だーーー"
        }
      },
      "attributes": [
        {
          "trait_type": "Mouth",
          "value": "Surprised"
        }
      ],
      "medium": {
        "en": "Oil on canvas",
        "ja": "キャンバスに油彩",
        "zh": "布面油画"
      },
      "edition": {
        "uniqueness": "unique work",
        "proofType": "ED",
        "number": 1,
        "totalNumber": 3,
        "note": {
          "en": "some extra notes in 1 or more languages"
        }
      },
      "contractTerms": {
        "royaltyRate": 15.7,
        "fileURL": "https://startrail.io/whitepaper/startrail_wp_en_v1.1.pdf"
      },
      "note": {
        "en": "note",
        "zh": "注意"
      },
      "thumbnailURL": "https://storage.googleapis.com/opensea-prod.appspot.com/puffs/3.png",
      "yearOfCreation": {
        "en": "around 2010-2020",
        "ja": "2010年から2020年頃"
      },
      "isDigital": true,
      "digitalDataHash": "sha256-247e4b904322a1dd0b148cd77e8627ec7d391251380880ab4621726ecb945ef5",
      "digitalComponents": [{
        "hash": "sha256-247e4b904322a1dd0b148cd77e8627ec7d391251380880ab4621726ecb945ef5",
        "category": "artwork"
      }],
      "attachmentFiles": [{
        "hash": "sha256-247e4b904322a1dd0b148cd77e8627ec7d391251380880ab4621726ecb945ef5",
        "category": "artwork"
      }],
      "name": "some nft name",
      "description": "some nft description",
      "image": "https://storage.googleapis.com/opensea-prod.appspot.com/puffs/3.png",
      "external_url": "https://openseacreatures.io/3"
    }
  ],
  isConverted: false,
  message: 'Requested metadata is already up to date',
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.startrail.io/startrail-sdk-js/startrail-api-methods/convertmetadata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
