功能
更新 Core Collection
Last updated April 8, 2026
updateCollection 和 updateCollectionPlugin 修改现有 Core Collection 的元数据和插件配置。
学习内容
- 更新 Collection 的名称或 URI
- 更新附加到 Collection 上的插件
Summary
创建后对 Core Collection 进行更新有两条指令。
updateCollection— 更改合集的name或uriupdateCollectionPlugin— 修改合集上现有插件的配置- 两者都需要
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 不受影响
- 通过
updateCollection的newUpdateAuthority参数可将updateAuthority转移给新账户
Quick Reference
| Instruction | JS 函数 | 使用场景 |
|---|---|---|
UpdateCollectionV1 | updateCollection | 更改 name 或 uri |
UpdateCollectionPluginV1 | updateCollectionPlugin | 修改现有插件配置 |
| 账户 | 必填 | 说明 |
|---|---|---|
collection | 是 | 要更新的 Collection |
authority | 是 | 必须是 updateAuthority |
payer | 是 | 支付交易费用 |
newUpdateAuthority | 否 | 将 Update Authority 转移给新账户 |
