> For the complete documentation index, see [llms.txt](https://ican.gitbook.io/ican-docs-in-chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ican.gitbook.io/ican-docs-in-chinese/ican.md).

# iCAN

什么是 iCAN？-- IC 上最好的易于使用的 Canister 管理平台。

## **背景**

1. 目前，开发者只能通过 NNS 钱包和 DFX 命令行来管理他们的容器。
2. NNS 钱包仅显示有关 Canister 的基本信息。并且开发者不能轻易使用NNS钱包管理Canister。只有Canister id没有其他信息，使得开发者无法方便地使用NNS钱包管理自己的canister。
3. 难以通过 DFX CLI 管理容器状态。

## **介绍**

**使用 UI 界面来方便的部署和管理您的 CANISTERS**

1. iCAN = IC + Canister。它是一个基于 IC 的链上 Canister 管理工具。
2. iCAN 帮助开发者通过图形界面管理 Canister，创建合约、下载 WebAssembly 模块、管理 Canister 状态指标等。

## 功**能**

1. **精细化管理**
   * Canister设置的动态更改
   * 更方便的容器管理
   * Canister的详细描述
2. **状态检测**
   * 支持直接使用ICP向充值Canister，直接将Cycles存入Canister
   * 及时反馈Canister状态，让开发者了解Canister当前状态并及时管理
3. **创建和删除**
   * 图形化的Canister管理界面
   * 能够创建和删除罐，并自动取回Cycles
4. **支持导入**
   * 之前创建的Canisters导入您自己的hub。
5. **WebAssembly 控制**
   * 下载最新的 WebAssembly文件

## 优势

iCAN开发者平台帮助开发者管理Canister。未来的目标是成为IC上的全面的合同管理平台。

1. &#x20;**在随机子网中创建Management Hub**
   * &#x20;通过部署在随机子网中的Hub，您可以选择要创建Canister的子网。
2. &#x20;**便捷的管理**
   * 你可以给Canister命名、添加标签或给出描述，这样你就可以方便地管理它们
3. **无信任管理**
   * 仅由您自己控制，它支持无需信任的托管服务。

## 公共接口

**介绍iCAN Canister和Hub Canister的公共接口。**

### **Type**

```
    module{
    
        public type Error = {
            #Invalid_Caller;
            #Invalid_CanisterId;
            #No_Wasm;
            #No_Record;
            #Insufficient_Cycles;
            #Ledger_Transfer_Failed : Nat; // value : log id
            #Create_Canister_Failed : Nat;
        };
    
        public type Canister = {
            name : Text;
            description : Text;
            canister_id : Principal;
            wasm : ?[Nat8];
        };
    
        public type Status = {
            cycle_balance : Nat;
            memory : Nat;
        };
    
        public type UpdateSettingsArgs = {
            canister_id : Principal;
            settings : canister_settings
        };
    
        public type TransformArgs = {
            icp_amount : Nat64; // e8s
            to_canister_id : Principal
        };
    
        public type DeployArgs = {
            name : Text;
            description : Text;
            settings : ?canister_settings;
            deploy_arguments : ?[Nat8];
            wasm : ?[Nat8];
            cycle_amount : Nat;
            preserve_wasm : Bool;
        };
    
        public type canister_settings = {
            freezing_threshold : ?Nat;
            controllers : ?[Principal];
            memory_allocation : ?Nat;
            compute_allocation : ?Nat;
        };
    
    };
```

### **iCAN Canister**

iCAN Canister 用于创建管理中心。

```
    // iCAN Canister Public Service Interface
    public type iCAN = actor{

        // get your own hubs' info (call this function use your identity)
        // @return array of (Hub Name, Hub Canister Id)
        getHub : query () -> async [(Text, Principal)];

        // get current hub wasm and cycle withdraw wasm in use
        // @return (hub wasm, cycle withdraw wasm)
        getWasms : query () -> async ([Nat8], [Nat8]);

        // get administrators of ican at present
        // @return array of administrators
        getAdministrators : query () -> async [Principal];

        // create canister management hub
        // @param name : hub name
        // @param amount : icp e8s amount
        createHub : (name : Text, amount : Nat64) -> async Result.Result<Principal, Error>;

        // add hub info to your hubs
        // @param name : hub name
        // @param hub_id : hub canister principal
        addHub : (name : Text, hub_id : Principal) -> async Text;

        // delete hub from your hub set
        deleteHub : (hub_id : Principal) -> async Result.Result<(), Error>;

        // transform icp to cycles and deposit the cycles to target cansiter
        transformIcp : (args : TransformArgs) -> async Result.Result<(), Error>;

    };
```

### **Hub Canister**

是用户部署的个人管理Canister。

```
    public type Hub = actor{

        // get current version hub canister's wasm
        // @return Wasm Version
        getVersion : query() -> async Nat;

        // get owners of this hub canister
        // @return owners array
        getOwners : query() -> async [Principal];

        // get status of hub canister ( owner only )
        getStatus : query() -> async Result.Result<Status, Error>;

        // get canisters managed by this hub ( owner only )
        getCanisters : query() -> async Result.Result<[Canister], Error>;

        // get wasm of specified canister ( owner only )
        getWasm : query (canister_id : Principal) -> async Result.Result<[Nat8], Error>;

        // put canister into hub ( not matter if not controlled by hub canister ) ( owner only )
        // @param c : should be put into hub canister
        putCanister : (c : Canister) -> async Result.Result<(), Error>;

        // deploy canister by hub canister  ( owner only )
        // @return #ok(new canister's principal) or #err(Error)
        deployCanister : (args : DeployArgs) -> async Result.Result<Principal, Error>;

        // update canister settings  ( owner only )
        updateCanisterSettings : (args : UpdateSettingsArgs) -> async Result.Result<(), Error>;

        // start the specify canister, which should be controlled by hub canister  ( owner only )
        // @param principal : target canister's principal
        startCanister : (principal : Principal) -> async Result.Result<(), Error>;

        // stop canister ( owner only )
        // @param principal : target canister's principal
        stopCanister : (principal : Principal) -> async Result.Result<(), Error>;

        // deposit cycles to target canister ( equal to top up to target canister)
        // @param id : target canister principal, cycle amount : how much cycles should be top up
        depositCycles(id : Principal, cycle_amount : Nat, ) : async Result.Result<(), Error>;

        // delete canister from hub canister and withdraw cycles from it ( owner only )
        // @param canister's principal
        delCanister : ( id : Principal ) -> async Result.Result<(), Error>;

        // install cycle wasm to hub canister ( owner only )
        // @param wasm : cycle wasm blob (you can deploy your own cycle wasm to your hub canister)
        installCycleWasm : (wasm : [Nat8]) -> async Result.Result<(), Error>;

        // change hub owner ( owner only )
        // @param : new owners array
        changeOwner : (newOwners : [Principal]) -> async Result.Result<(), Error>;

    };
```

## 结构图

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FXv7zey8Jwbz3MitxDMBt%2F%E6%9C%AA%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B6_\(1\).jpg?alt=media\&token=60141b45-f586-4dbb-a4de-2eff1359f3ee)

## 用户使用手册

#### 登录

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FAUS7QOvSIaZiKxov9Vc7%2FUntitled.png?alt=media\&token=d414f126-066b-4021-b28d-eb6695e9958f)

点击图标使用II(Internet Identity)进行登录。

### 创建Management Hub

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FsNoOM15HXUwzMaoXBgok%2FUntitled%201.png?alt=media\&token=60513ba3-8350-4359-b5ce-ef16f0e439e9)

1. 使用钱包或交易所充值ICP到以上地址( 这是一个Canister持有的地址，所以充值后不能转出，请根据需要充值， 如果你需要退回ICP，请联系我们)。
2. 输入Management Hub的名字和用来创建Management hub的ICP数量，除去转账和创建canister所需要的手续费， 多余的ICP将转换成cycles存入Management hub
3. 点击Create进行创建，这一过程会比较漫长，请耐心等待

### Management Hub 界面

Management Hub相当于你私人的canister管理器，它是一个仅由你控制的canister。

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FhK5mcOIpm1sFqLRJy1CC%2FUntitled%202.png?alt=media\&token=5cefddf7-19fd-48e6-959f-e66c6fcb0a3c)

#### Hub Status

此处显示的是Hub的状态信息，包括内存使用情况，cycles余额。

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FaW2akXKht553Nv7cvs2P%2FUntitled%203.png?alt=media\&token=7eb4f39f-bb2d-4e67-9c4e-1ca79b73e0a7)

接下来在Management Hub进行的所有操作，包括创建canister，充值canister等， 都使用的是此处的cycles余额，所以如果你的cycles不多的话可以点击右上角的add cycles进行充值。

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FMH2onrCsWESEpVTXDL5o%2FUntitled.png?alt=media\&token=081da4bf-ec4e-4c08-9864-25096ebc8686)

输入你想要充值的数量，点击add，接下来耐心等待充值完毕（icp转换成cycles需要一点时间）。

#### Create canister

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FInFV3ePZChg11kKwqIaM%2FUntitled%205.png?alt=media\&token=61a2695e-9b3b-4356-8a24-7f20aa276690)

&#x20;1\. 点击这个加号“+”按钮

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FqAwVNwO746K6HZxz0aQj%2FUntitled1.png?alt=media\&token=cacd0a66-74ce-492a-96e2-0447b4ee073f)

&#x20;2\. 输入canister的名字和介绍

* Init cycles balance 是初始的cycles 余额， 最小值为0.2T。

&#x20;3\. 点击wasm file上传你编译好的canister， 请保持文件大小在2m以下。

* 如果你需要对以下三个参数进行修改，请点击advanced

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FCkMfdDxqTDf8czOJzb6C%2FUntitled%207.png?alt=media\&token=07ab58b3-0e39-4cea-9ed6-442d2eb47486)

&#x20;4\. 点击create， 等待创建完成。

### 对canister进行操作

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2F39gcrU9TacYgDJp0a2Dl%2FUntitled%208.png?alt=media\&token=5dc4cf49-13b1-409a-9b20-456453498c93)

上面是一个创建成功的canister的例子

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2F0UX2qZeK758hPr8M8LfV%2FUntitled%209.png?alt=media\&token=6c2887d9-b7aa-4d30-badf-04051734c26f)

点击可以展开显示详细信息 右上角可以跳转到icscan查看该canister。

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FPj9qqVshX7An2lX0B657%2FUntitled%2010.png?alt=media\&token=fa963c18-5b8a-4659-8a77-b1975528d1ed)

点击“选项”按钮来操作Canisters。提供了以下四种方法: 安装(Install)、添加cycles(Add cycles)、删除(Delete)、停止和启动(Stop \&Start)。

#### Install

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FlWe1k7CfAiSrgRV2l594%2FUntitled5.png?alt=media\&token=be70e801-5ac3-40d1-a922-808a4aee7f96)

点击上传已编译的 wasm 文件，然后根据需要选择"install"、 "reinstall"和"upgrade" 模式。关于这三种模式请查看[官网文档](https://smartcontracts.org/docs/current/references/ic-interface-spec#icmethod-install_code)。

#### Add cycles

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2F2QzSh3sw2tcaQxoCZvVT%2FUntitled4.png?alt=media\&token=5618d453-3099-450e-9645-d212753a35c1)

添加cycles， 使用的是Management Hub中的cycles。

#### Delete

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2Fj5gmSBmcOT1hHbX8r6iQ%2FUntitled2.png?alt=media\&token=10603f1d-5171-45b2-8222-be6bd247333f)

如果你要删除这个canister， 点击delete，在弹窗中点击确定， 删除后其cycles余额会回到manage hub中（如果cycles余额小于0.01T则不回收）。

#### Stop & Start

![](https://457410012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl3loFefEpTCaQv0oE0MI%2Fuploads%2FHfyxXFYI2RMknEogS5Aj%2FUntitled6.png?alt=media\&token=f81aa632-1f1d-4f49-871b-8273949faa7b)

停止或开启这个canister。

## **路线图**

**2022Q2** MVP 发布。

**2022Q3**全面支持当前的 Canister 管理。

1. 导入之前创建的容器
2. 支持部署 Actor Class Canister
3. 支持向 Hub Canister 添加更多管理员（支持团队合作）
4. 开源 iCAN 并交给社区 DAO

支持一键创建特定类型的Canister（asset canisters, NFT canisters）并上传前端资产。

**2022Q4上线**日志管理平台。支持数据恢复。

**2022Q4-2023**成为IC的最佳Canister管理平台和开发者基础设施。

## **团队**

Mixlabs是由亚洲顶尖大学和社区开发者组成的区块链方向前沿技术实验室。主要从事区块链方向的前沿技术研究、孵化和生态支持。
