功能

更新 Core Collection

Last updated April 8, 2026

updateCollectionupdateCollectionPlugin 修改现有 Core Collection 的元数据和插件配置。

学习内容

  • 更新 Collection 的名称或 URI
  • 更新附加到 Collection 上的插件

Summary

创建后对 Core Collection 进行更新有两条指令。

  • updateCollection — 更改合集的 nameuri
  • updateCollectionPlugin — 修改合集上现有插件的配置
  • 两者都需要 updateAuthority 签名
  • 合集级别插件的变更会传播到继承它们的成员 Asset

跳转至: 更新元数据 · 更新插件 · 错误处理

前提条件

  • 以合集的 updateAuthority 作为签名者配置的 Umi — 参见获取 Collection 来检索该值
  • 要更新的 collection 地址

更新合集元数据

updateCollection 更改现有 Collection 的 name 和/或 uri。只传入需要更改的字段。

更新 Core Collection

update-collection.ts
import { publicKey } from '@metaplex-foundation/umi'
import { updateCollection } from '@metaplex-foundation/mpl-core'
const collectionAddress = publicKey('1111111111111111111111111111111')
await updateCollection(umi, {
collection: collectionAddress,
name: 'My Updated Collection',
uri: 'https://example.com/new-uri.json',
}).sendAndConfirm(umi)

更新合集插件

updateCollectionPlugin 更改已附加到 Collection 上的插件配置。以下示例更新了 Royalties 插件的基点和创作者分成。

更新 Core Collection 插件

update-collection-plugin.ts
import { publicKey } from '@metaplex-foundation/umi'
import { updateCollectionPlugin, ruleSet } from '@metaplex-foundation/mpl-core'
const collectionAddress = publicKey('1111111111111111111111111111111')
const newCreator = publicKey('5555555555555555555555555555555')
await updateCollectionPlugin(umi, {
collection: collectionAddress,
plugin: {
type: 'Royalties',
basisPoints: 400,
creators: [{ address: newCreator, percentage: 100 }],
ruleSet: ruleSet('None'),
},
}).sendAndConfirm(umi)

常见错误

Authority mismatch

您没有使用合集的 updateAuthority 进行签名。获取合集来检查:

const collection = await fetchCollection(umi, collectionAddress)
console.log(collection.updateAuthority) // 必须与 umi.identity 匹配

Notes

  • 要添加合集上尚不存在的插件,请使用 addCollectionPlugin 而非 updateCollectionPlugin
  • 更新合集级别的插件会影响继承它的所有 Asset — 拥有同类型自有插件的 Asset 不受影响
  • 通过 updateCollectionnewUpdateAuthority 参数可将 updateAuthority 转移给新账户

Quick Reference

InstructionJS 函数使用场景
UpdateCollectionV1updateCollection更改 nameuri
UpdateCollectionPluginV1updateCollectionPlugin修改现有插件配置
账户必填说明
collection要更新的 Collection
authority必须是 updateAuthority
payer支付交易费用
newUpdateAuthority将 Update Authority 转移给新账户
源码链接
UpdateCollectionV1GitHub
UpdateCollectionPluginV1GitHub