Explorar o código

Change collection example (#300)

* fix typo

* warn immutability

* Update src/pages/core/update.md

Co-authored-by: Tony Boyle <81017245+tonyboylehub@users.noreply.github.com>

---------

Co-authored-by: Tony Boyle <81017245+tonyboylehub@users.noreply.github.com>
MarkSackerberg hai 10 meses
pai
achega
a1e0df0b92
Modificáronse 2 ficheiros con 45 adicións e 3 borrados
  1. 44 2
      src/pages/core/update.md
  2. 1 1
      src/pages/index.md

+ 44 - 2
src/pages/core/update.md

@@ -111,11 +111,53 @@ pub async fn update_asset() {
 {% /dialect %}
 {% /dialect-switcher %}
 
+## Change the Collection of a Core Asset
+
+Here is how you can use our SDKs to change the collection of a Core Asset.
+
+{% dialect-switcher title="Change the collection of a Core Asset" %}
+{% dialect title="JavaScript" id="js" %}
+
+```ts
+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);
+
+```
+
+{% /dialect %}
+{% /dialect-switcher %}
+
 ## Making a Core Asset Data Immutable
 
-Here is how you can use our SDKs to update an MPL Core Asset.
+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](/core/guides/immutability).
 
-{% dialect-switcher title="Update an Asset" %}
+{% callout type="warning" title="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.
+
+{% /callout %}
+
+{% dialect-switcher title="Make a Core Asset Immutable" %}
 {% dialect title="JavaScript" id="js" %}
 
 ```ts

+ 1 - 1
src/pages/index.md

@@ -6,4 +6,4 @@ description: One place for all Metaplex developer resources.
 
 The Metaplex Protocol is a decentralized platform built on the Solana blockchain, designed to facilitate the creation, sale, and management of digital assets. It offers tools and standards for developers, creators and businesses to build decentralized applications. Known for powering digital assets including NFTs, fungible tokens, RWAs, gaming assets, DePIN assets and more, Metaplex is one of the most widely used blockchain protocols and developer platforms, with over 550 million assets minted across 55 million unique wallets.
 
-On the following page you can find Metaplex's programs and tools. We're excited to see what you build with Metaplex. If you have questions please reach out in our [Discord!](https://discord.com/invite/metaplex)!
+On the following page you can find Metaplex's programs and tools. We're excited to see what you build with Metaplex. If you have questions please reach out in our [Discord](https://discord.com/invite/metaplex)!