> ## Documentation Index
> Fetch the complete documentation index at: https://docs.injective.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Factory

InjectiveのToken Factoryモジュールは、Mint + Burnモデルを使用して、ユーザーとコントラクトが新しいネイティブトークンを作成し、ネイティブトークンとCW20トークンをスワップできるようにします。これは、異なるソースからのアセットをネイティブbank denomとして表現することが、exchange、auction、insurance fundsなど、他のオンチェーンモジュールへのアクセスをユーザーに許可するために不可欠であるため、チェーン上に持つべき重要な機能です。Token Factory denomは次の形式です: `factory/{creator address}/{subdenom}`。

createrとして機能する`CW20AdapterContract`と組み合わせることで、CW20アセットをInjective上でToken Factory denomとしてネイティブに表現できます。仕組みとしては、CW20アセットは`CW20AdapterContract`によって保持され、injectiveアドレスに対してfactory denomとしてミントされます。CW20に戻したい場合、bankモジュールからburnされ、`CW20AdapterContract`からオーナーアドレスに解放されます。

## 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,
  }),
})

// その後、メッセージをトランザクションにパックし、署名してチェーンにブロードキャストします
```

## 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 は6桁の小数を持つため、チェーン上では次のように表現されます

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

// その後、メッセージをトランザクションにパックし、署名してチェーンにブロードキャストします
```
