> ## Documentation Index
> Fetch the complete documentation index at: https://injectivelabs-mintlify-25e241d4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Factory

TokenFactory 代币是原生集成到链的 bank 模块中的代币。它们的名称采用 `factory/{creatorAddress}/{subdenom}` 格式。由于代币按创建者地址命名空间，这使得代币铸造可以无需许可，因为不需要解决名称冲突。

这种集成提供了对所有资产总供应量的跟踪和查询支持，这与 CW20 标准不同，后者需要直接查询智能合约。因此，建议使用 TokenFactory 标准。例如，Helix 或 Mito 等产品是建立在 Injective exchange 模块上的，该模块专门使用 bank 代币。TokenFactory 代币可以通过 injectived CLI 以及智能合约创建。通过 Wormhole 桥接到 Injective 的代币也是 TokenFactory 代币。

## CW20 适配器

`CW20AdapterContract` 允许 CW20 资产在 Injective 上以 Token Factory denom 的形式原生表示。CW20 资产由适配器合约持有，并作为 factory denom 铸造给对应的 Injective 地址。当赎回回 CW20 时，它们会从 bank 模块中销毁，并从适配器合约中解锁回所有者地址。

### 将 factory denom 赎回为 CW20

```ts theme={null}
import {
  MsgExecuteContractCompat,
  ExecArgCW20AdapterRedeemAndTransfer,
} from '@injectivelabs/sdk-ts/core/modules'

const CW20_ADAPTER_CONTRACT = 'inj...'
const contractCw20Address = 'inj...'
const injectiveAddress = 'inj...'

const message = MsgExecuteContractCompat.fromJSON({
  sender: injectiveAddress,
  contractAddress: CW20_ADAPTER_CONTRACT,
  funds: {
    denom: `factory/${CW20_ADAPTER_CONTRACT}/${contractCw20Address}`,
    amount: actualAmount.toFixed(),
  },
  execArgs: ExecArgCW20AdapterRedeemAndTransfer.fromJSON({
    recipient: injectiveAddress,
  }),
})

// Then pack the message in a transaction, sign it and broadcast to the chain
```

### 将 CW20 转换为 factory denom

```ts theme={null}
import {
  ExecArgCW20Send,
  MsgExecuteContractCompat,
} from '@injectivelabs/sdk-ts/core/modules'

const CW20_ADAPTER_CONTRACT = 'inj...'
const contractCw20Address = 'inj...'
const injectiveAddress = 'inj...'
const amount = '1000000' // 1 USDT represented as on the chain as it has 6 decimals

const message = MsgExecuteContractCompat.fromJSON({
  contractAddress: contractCw20Address,
  sender: injectiveAddress,
  execArgs: ExecArgCW20Send.fromJSON({
    amount,
    contractAddress: CW20_ADAPTER_CONTRACT,
  }),
})

// Then pack the message in a transaction, sign it and broadcast to the chain
```

## 延伸阅读

* [代币发布指南](../../developers-defi/token-launch/) —— 在 Injective 上创建代币的分步指南
* [Token Factory 模块参考](../../developers-native/injective/tokenfactory/) —— 详细的模块规范
