> For the complete documentation index, see [llms.txt](https://toshio.gitbook.io/icp-rust-cdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://toshio.gitbook.io/icp-rust-cdk/tips/token.md).

# Token

ICP上でTokenの取り扱う規格として、EthereumにおけるERC-20のように『ICRC-1』があります。

## Specificaiton

| Proposal | Description                                                                                         | did                                                                                   |
| -------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| ICRC-1   | [Token Standard](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/README.md)            | [ICRC-1.did](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/ICRC-1.did) |
| ICRC-2   | [Approve and Transfer From](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md) | [ICRC-2.did](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/ICRC-2.did) |

## トークン発行

ICP上でトークンを発行する方法について公式ドキュメントがあります。

<https://internetcomputer.org/docs/current/developer-docs/integrations/icrc-1/deploy-new-token>

試しにローカルPC上でつくってみることにします。

### (1) ダウロードスクリプト

```bash
$ curl -o download_latest_icrc1_ledger.sh "https://raw.githubusercontent.com/dfinity/ic/master/rs/rosetta-api/scripts/download_latest_icrc1_ledger.sh"
```

※2023年9月19日時点で、Githubにコミットされているファイル名が「\_ledger.sh」ではなく、「\_leger.sh」となっているので注意

### (2) ダウンロードスクリプトの実行

```bash
$ bash download_latest_icrc1_ledger.sh
Found artifacts for commit 21fa6190f619ae1179e3511092cd5644f61ceb3e. Downloading icrc1_ledger.did and icrc1_ledger.wasm.gz
```

※jqコマンドがインストールされている必要があります。

### (3) dfx.json

```json
{
  "canisters": {
    "icrc1-ledger": {
      "type": "custom",
      "wasm": "icrc1-ledger.wasm",
      "candid": "icrc1-ledger.did"
    }
  }
}
```

### (4) deploy\_token.sh修正

解説ページに載っているスクリプトをベースに、配備用スクリプトを用意します。

[**deploy\_token.sh**](https://github.com/toshio/icptest/blob/master/tips/deploy_token.sh)

```bash
#!/bin/bash

# Change the variable to "ic" to deploy the ledger on the mainnet.
export NETWORK=local

# Change the variable to the principal that can mint and burn tokens.
export MINTER_PRINCIPAL=$(dfx identity get-principal)

# Change the variable to the principal that controls archive canisters.
export ARCHIVE_CONTROLLER=$(dfx identity get-principal)

export TOKEN_NAME="TM Token"
export TOKEN_SYMBOL=XTM

dfx deploy --network ${NETWORK} icrc1-ledger --argument "(variant { Init = 
      record {
        token_name = \"${TOKEN_NAME}\";
        token_symbol = \"${TOKEN_SYMBOL}\";
        minting_account = record { owner = principal \"${MINTER_PRINCIPAL}\";};
        initial_balances = vec {};
        metadata = vec {};
        transfer_fee = 10;
        archive_options = record {
          trigger_threshold = 2000;
          num_blocks_to_archive = 1000;
          controller_id = principal \"${ARCHIVE_CONTROLLER}\";
        }
}})"
```

### (5) deploy

```bash
$ dfx start --background --clean
$ bash deploy_token.sh
```

### (6) deploy

$ dfx start --background --clean

## その他情報

### The Internet Computer Token Standards: A Comparison

Fungible Tokenの規格として、ICRC-1以外にも、IS20、DIP20、EXTといった規格があるようです。

<https://www.blog.bitfinity.network/the-internet-computer-token-standards-a-comparison/>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://toshio.gitbook.io/icp-rust-cdk/tips/token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
