AlgoKit项目初始化 create-project

AlgoKit项目初始化技能用于快速创建和搭建Algorand区块链上的去中心化应用(dApp)和智能合约项目。它通过官方模板引导,自动化设置开发环境,配置工具链,并提供生产就绪的项目结构。关键词包括:Algorand智能合约,AlgoKit脚手架,dApp开发,区块链项目初始化,智能合约模板,TypeScript/Python开发。

DApp开发 0 次安装 0 次浏览 更新于 3/4/2026

name: 创建项目 description: 为 Algorand 去中心化应用和智能合约引导生产就绪的 AlgoKit 项目。在初始化新的 Algorand 智能合约项目、从头设置开发环境或使用预配置工具搭建 dApp 时使用。强烈触发词包括“创建新项目”、“初始化新的 Algorand 应用”、“启动新的智能合约”、“设置 AlgoKit”、“搭建 dApp”、“algokit init”。

AlgoKit 项目初始化

使用 AlgoKit 官方模板创建新的 Algorand 项目。

概述 / 核心工作流

  1. 与用户确认项目详情(名称、模板、自定义项)
  2. 使用适当的标志运行 algokit init
  3. 处理任何初始化错误
  4. 提供构建/测试的后续步骤

如何操作

  1. 与用户确认项目详情:

    • 项目名称(目录名)
    • 模板选择(TypeScript 或 Python)
    • 任何自定义项(--no-git--no-bootstrap、作者姓名)
    • 对于 TypeScript:为生产项目确认生产预设
  2. 运行初始化命令:

    TypeScript(生产预设):

    algokit init -n <项目名称> -t typescript --answer preset_name production --answer author_name "<姓名>" --defaults
    

    TypeScript(入门预设):

    algokit init -n <项目名称> -t typescript --answer author_name "<姓名>" --defaults
    

    Python(生产预设):

    algokit init -n <项目名称> -t python --answer preset_name production --answer author_name "<姓名>" --defaults
    

    Python(入门预设):

    algokit init -n <项目名称> -t python --answer author_name "<姓名>" --defaults
    

    使用自定义选项(无 git,无引导):

    algokit init -n <项目名称> -t typescript --no-git --no-bootstrap --defaults
    
  3. 处理错误:

    • 检查项目目录是否已存在
    • 验证 AlgoKit 是否已安装:algokit --version
    • 确保目标目录可写
    • 有效模板:typescriptpythontealscriptreactfullstackbase
  4. 提供后续步骤:

    • cd <项目名称>
    • algokit project run build — 编译合约
    • algokit project run test — 运行测试套件
    • algokit localnet start — 启动本地网络(如果部署)
    • algokit project run deploy — 将合约部署到本地网络

重要规则 / 指南

  • 执行前始终与用户确认 — 未经明确确认,切勿运行 algokit init
  • 默认使用 TypeScript — 推荐用于生产应用
  • 使用生产预设 — 适用于任何项目,因为它包含测试框架和部署脚本
  • 包含作者姓名 — 传递 --answer author_name "<姓名>" 以进行归属
  • 使用 --defaults — 接受所有其他默认值以进入非交互模式

常见变体 / 边缘情况

场景 方法
使用 TypeScript 部署的 Python --answer deployment_language "typescript"
现有目录 检查并警告目录是否已存在
无 Git 初始化 使用 --no-git 标志
无依赖项安装 使用 --no-bootstrap 标志
自定义作者姓名 --answer author_name "您的姓名"
全栈(前端 + 合约) 使用 -t fullstack 模板
仅 React 前端 使用 -t react 模板
独立(无工作区) 使用 --no-workspace 标志
从示例初始化 使用 algokit init example 子命令

参考 / 延伸阅读