@defuse-protocol/crosschain-assetid

中文文档
1.15.0发布于 2026/10/23TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5351

bash npm install @defuse-protocol/crosschain-assetid

原始使用文档
文档目录16 节
  1. Installation
  2. Usage
  3. Purpose
  4. Format
  5. Components
  6. Examples
  7. Fungible tokens
  8. NFTs
  9. Native coins
  10. Non-EVM standards
  11. Rationale & Design Choices
  12. 1. URL safety
  13. 2. Human-readable but unambiguous
  14. 3. Multi-asset support
  15. 4. Bridged / wrapped assets
  16. Object Form

1cs_v1 — Unified Cross-Chain Asset Identifier

Installation

npm install @defuse-protocol/crosschain-assetid

Usage

import {parse1cs, stringify1cs} from '@defuse-protocol/crosschain-assetid';

const assetid = stringify1cs({
  version: "v1",
  chain: "eth",
  namespace: "erc20",
  reference: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
})

const obj = parse1cs("1cs_v1:eth:erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48")

Purpose

1cs_v1 is a URL-safe, compact, human-readable identifier format for representing any asset (crypto token, NFT, native coin, wrapped/bridged asset, or even fiat) across chains in a consistent way.

It is designed to:

  • Let apps refer to assets unambiguously without chain-specific parsing logic.
  • Work cross-chain and cross-standard — one format for EVM, Solana, Cosmos, NEAR, Stellar, Aptos, Sui, fiat, etc.
  • Be safe in URLs, filenames, and APIs without extra escaping.
  • Enable simple parsing into an object with predictable fields.
  • Serve as a unified key for balances, swaps, bridges, quotes, and off-ramps.

Format

1cs_v1:<chain>:<namespace>:<reference>[:<selector>]

Components

PartRequired?Description
1cs_v1✅Format prefix and version. 1cs stands for 1ClickSwap.
<chain>✅Lowercase slug (e.g. eth, eth-sepolia, solana, near, polygon), can encode testnet in slug.
<namespace>✅Asset standard/kind: erc20, erc721, spl, near-nft, aptos-coin, aptos-fa, fiat, etc.
<reference>✅Contract/mint/account/denom/issuer — URI-encoded to safely hold :, /, spaces, unicode, etc.
<selector>optionalSub-asset selector: token ID, module struct, Stellar code, etc. — also URI-encoded.

Examples

Fungible tokens

1cs_v1:eth:erc20:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48    # USDC on Ethereum
1cs_v1:base:erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913   # USDC on Base
1cs_v1:fiat:iso4217:USD                                        # US Dollar (fiat)

NFTs

1cs_v1:eth:erc721:0x1234567890abcdef1234567890abcdef12345678:42
1cs_v1:near:nep171:apes.coolnft.near:series%3A1%2Fblue%3A42

Native coins

1cs_v1:eth:native:coin
1cs_v1:zcash:native:coin

Non-EVM standards

1cs_v1:solana:spl:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
1cs_v1:aptos:aptos-coin:0x1%3A%3Aaptos_coin%3A%3AAptosCoin
1cs_v1:aptos:aptos-fa:0x0b0b819dcf8d9517ed14195a95adfae6a49bfdb49de33a532ca0aa7ee588e8e0

Aptos has two fungible-token standards, so reference takes a different shape for each:

  • aptos-coin — legacy Coin<T> standard. reference is the fully-qualified Move struct type (address::module::Struct).
  • aptos-fa — Fungible Asset standard (AIP-21). reference is the plain object address holding the 0x1::fungible_asset::Metadata resource.

Rationale & Design Choices

1. URL safety

We encode reference and selector with encodeURIComponent so they are safe in URLs.

2. Human-readable but unambiguous

  • Prefix (1cs_v1) makes it clear what format is in use. Easy greppable across codebase.
  • Chain slug + namespace covers most identification needs without extra lookups.
  • Works for both blockchain and fiat.

3. Multi-asset support

selector cleanly supports ERC-1155 IDs, Stellar asset codes, Cosmos token sub-denoms, Aptos/Sui struct names, etc.

4. Bridged / wrapped assets

The ID identifies the on-chain representation. If you need to express the origin, bridge, issuer, or other metadata — pass it as query params or in your object model, not in the core ID.


Object Form

Parsing a 1cs_v1 string gives you:

interface OneCsAsset {
    version: "v1";
    chain: string;      // e.g. "eth", "near", "fiat"
    namespace: string;  // e.g. "erc20", "spl", "native"
    reference: string;  // decoded from URI
    selector?: string;  // decoded from URI if present
}

Example:

1cs_v1:near:nep171:apes.coolnft.near:series%3A1%2Fblue%3A42
↓
{
  version: "v1",
  chain: "near",
  namespace: "nep171",
  reference: "apes.coolnft.near",
  selector: "series:1/blue:42"
}

版本与发布记录

@defuse-protocol/crosschain-assetid 共发布 22 个版本,首次发布于 2025/09/10;过去 12 个月发布了 19 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.15.0latest2026/10/2319 天前
1.14.02026/10/2121 天前
1.13.02026/09/181 个月前
1.12.02026/09/171 个月前
1.11.02026/09/102 个月前
1.10.02026/09/082 个月前

关于 @defuse-protocol/crosschain-assetid 的常见问题

@defuse-protocol/crosschain-assetid 是什么?

bash npm install @defuse-protocol/crosschain-assetid

如何安装 @defuse-protocol/crosschain-assetid?

在项目目录运行 npm install @defuse-protocol/crosschain-assetid,或使用 pnpm add / yarn add / bun add。

@defuse-protocol/crosschain-assetid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@defuse-protocol/crosschain-assetid 支持 ESM 还是 CommonJS?

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

@defuse-protocol/crosschain-assetid 可以商用吗?

@defuse-protocol/crosschain-assetid 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@defuse-protocol/crosschain-assetid 的下载量有多少?

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

@defuse-protocol/crosschain-assetid 还在维护吗?

最新版本 1.15.0 发布于 2026/10/23(19 天前);至今共发布 22 个版本,其中过去 12 个月发布了 19 个;首次发布于 2025/09/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。