Features
Updating Assets
The update authority or delegate of a Core Asset has the ability to change some of the Asset's data.
Updating a Core Asset
Here is how you can use our SDKs to update an MPL Core Asset.
Update an Asset
import { publicKey } from '@metaplex-foundation/umi'
import { update, fetchAsset } from '@metaplex-foundation/mpl-core'
const assetId = publicKey('11111111111111111111111111111111')
const asset = await fetchAsset(umi, assetId)
// Optional: If the Asset is in a collection fetch the collection
const collectionId = publicKey('2222222222222222222222222222222')
const collection = await fetchCollection(umi, collectionId)
await update(umi, {
asset,
// Optional: Collection is only required if Asset is part of a collection
collection,
name: 'New Nft Name',
uri: 'https://example.com/new-uri',
}).sendAndConfirm(umi)
Change the Collection of a Core Asset
Here is how you can use our SDKs to change the collection of a Core Asset.
Change the collection of a Core Asset
import { publicKey } from "@metaplex-foundation/umi";
import {
update,
fetchAsset,
fetchCollection,
updateAuthority,
} from "@metaplex-foundation/mpl-core";
const assetId = publicKey("11111111111111111111111111111111");
const asset = await fetchAsset(umi, assetId);
const oldCollectionId = publicKey("22222222222222222222222222222222");
const collection = await fetchCollection(umi, oldCollectionId);
const newCollectionId = publicKey("33333333333333333333333333333333");
const updateTx = await update(umi, {
asset,
name: "Updated Asset",
collection,
newUpdateAuthority: updateAuthority("Collection", [newCollectionId]),
}).sendAndConfirm(umi);
Making a Core Asset Data Immutable
Here is how you can use our SDKs to make a Core Asset fully immutable. Be aware that there are different levels of immutability described in the immutability Guide.
Important
This is a destructive action and will remove the ability to update the asset.
It will also remove the asset from any collections it was in. To make collection assets immutable you will need to change the update authority of the collection.
Make a Core Asset Immutable
import { publicKey } from '@metaplex-foundation/umi'
import { update, fetchAsset } from '@metaplex-foundation/mpl-core'
const assetId = publicKey('11111111111111111111111111111111')
const asset = await fetchAsset(umi, asset)
await update(umi, {
asset: asset,
newUpdateAuthority: updateAuthority('None'),
}).sendAndConfirm(umi)