@cardinal/namespaces

中文文档
6.0.0发布于 2023/03/08AGPL-3.0ESM + CJS近 30 天下载 2569

Cardinal namespaces SDK

原始使用文档
文档目录7 节
  1. Background
  2. Packages
  3. Addresses
  4. Getting Started
  5. Documentation
  6. Questions & Support
  7. License

Cardinal Namespaces

License Release

A protocol for minting NFTs and subscriptions

Background

A namespace can be thought of as a rental dispenser with a templated set of parameters that allow the NFTs to be programmatically minted and rented on demand. Similar in ways to the Metaplex candy-machine, this works by minting the NFT and subsequently wrapping it in a token manager of the configured parameters. When it is returned to the namespace, it can be rented again by a new user.

  • Usernames
    • In renting a username from a given namespace, you may be renting the right to play a game, access a service, or participate in a DAO. The username comes in the form of a managed NFT that sits in your wallet for the duration of the rental.
  • Verified ownership
    • Holding a rented, managed NFT from a namespace that has previously verified your identity can allow you to assert proven ownership of something within that namespace.
  • Subscriptions
    • A namespace can be setup to offer subscription-based access to gated content. When a user attempts to access the content, the provider can trivially check for ownership of the NFT.
  • Keys / Tickets
    • A namespace could represent a room in a hotel for which temporary access could be rented out. The rented key could also have have a usage-based expiration and be used as a ticket to an event.
  • Badges / Certificates
    • A namespace could be setup to rent out badges or certifications to a specific set of users. A user could be approved by the namespace and subsequently claim their badge that could be verified as issued and managed by that namespace.

Packages

PackageDescriptionVersionDocs
cardinal-namespacesOn-demand NFT mintingCrates.ioDocs.rs
@cardinal/namespacesTypeScript SDK for namespacesnpmDocs

Addresses

Program addresses are the same on devnet, testnet, and mainnet-beta.

Getting Started

git clone https://github.com/cardinal-labs/cardinal-namespaces.git
cd cardinal-namespaces
make

Documentation

Namepsace

Namespaces are the base component of the protocol. A namespace is a PDA owned by the program that forms a logical grouping of NFTs under a common name. Often similar to a TLD (top-level domain), but the use of a namespace can vary widely. Essentially a namespace is the creator of tokens that belongs in the namespace. It contains an authority who can update the parameters of the namespace, and when users claim entries in a namespace, they are issued by the namespace.

#[account]
pub struct Namespace {
    pub bump: u8,
    pub name: String,
    pub update_authority: Pubkey,
    pub rent_authority: Pubkey,
    pub approve_authority: Option<Pubkey>,
    pub schema: u8,
    pub payment_amount_daily: u64,
    pub payment_mint: Pubkey,
    pub min_rental_seconds: i64,
    pub max_rental_seconds: Option<i64>,
    pub transferable_entries: bool,
}

Name Entry

Namespaces are a collection of name entries. Each name entry stores information related to a specific name in a namespace. Most importantly, the name is derived from the name and the namespace, so every entry is unique to a given namespace. The entry mostly serves to map a string name to an NFT (mint address). Whoever is the holder of that NFT has the ability to set the entry data and also map their address back to that name using the reverse_entry.

Name entry NFTs are dynamically generated using cardinal-generator.

Name entries are issued by the namespace according to the paramaters of the namespace. The namespaces use the cardinal-token-manager to create revocable and expiring NFTs that represent each entry. This setup allows for subscriptions, and revocable badges issued by a namespace.

#[account]
pub struct Entry {
    pub bump: u8,
    pub namespace: Pubkey,
    pub name: String,
    pub data: Option<Pubkey>,
    pub reverse_entry: Option<Pubkey>,
    pub mint: Pubkey,
    pub is_claimed: bool,
    pub claim_request_counter: u32,
}

Questions & Support

If you are developing using Cardinal namespaces contracts and libraries, feel free to reach out for support on Discord. We will work with you or your team to answer questions, provide development support and discuss new feature requests.

For issues please, file a GitHub issue.

https://discord.gg/cardinallabs

License

Cardinal Protocol is licensed under the GNU Affero General Public License v3.0.

In short, this means that any changes to this code must be made open source and available under the AGPL-v3.0 license, even if only used privately.

版本与发布记录

@cardinal/namespaces 共发布 177 个版本,首次发布于 2022/01/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
6.0.0latest2023/03/083 年前
5.0.12023/03/013 年前
5.0.02023/02/063 年前
5.0.0-beta.02023/02/063 年前
4.1.612022/11/303 年前
4.1.602022/11/273 年前

关于 @cardinal/namespaces 的常见问题

@cardinal/namespaces 是什么?

Cardinal namespaces SDK

如何安装 @cardinal/namespaces?

在项目目录运行 npm install @cardinal/namespaces,或使用 pnpm add / yarn add / bun add。

@cardinal/namespaces 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cardinal__namespaces 是否存在。

@cardinal/namespaces 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cardinal/namespaces 可以商用吗?

@cardinal/namespaces 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@cardinal/namespaces 的下载量有多少?

根据 npm 官方下载统计,@cardinal/namespaces 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,569 次,日均约 86 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cardinal/namespaces 还在维护吗?

最新版本 6.0.0 发布于 2023/03/08(3 年前);至今共发布 177 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/01/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。