功能
获取 Core Collection
Last updated April 8, 2026
fetchCollection 通过地址从 Solana 获取 Core Collection 账户并将其反序列化为类型化对象。
Summary
fetchCollection 读取 Collection 账户并返回所有链上字段 — 名称、URI、Update Authority、插件数据和成员数量。
- 需要合集的公钥
- 返回包含所有链上字段的类型化
Collection对象 - 如果地址不是有效的 Collection 账户则抛出错误
通过地址获取 Collection
将合集的公钥传入 fetchCollection 以获取账户。
获取 Core Collection
fetch-collection.ts
import { fetchCollection } from '@metaplex-foundation/mpl-core'
import { publicKey } from '@metaplex-foundation/umi'
const collectionId = publicKey('11111111111111111111111111111111')
const collection = await fetchCollection(umi, collectionId)
console.log(collection)
Notes
- 如果地址不存在或不是 Core Collection 账户,
fetchCollection会抛出错误 currentSize反映合集中当前的 Asset 数量;numMinted是历史总数- 在写入操作后验证状态,请在
sendAndConfirm之后调用fetchCollection
Quick Reference
| 项目 | 值 |
|---|---|
| JS 函数 | fetchCollection |
| 必填参数 | 合集公钥 |
| 返回值 | Collection 对象 |
| 源码 | GitHub |
