create-aptos-project
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Aptos Project Skill
创建Aptos项目Skill
Purpose
用途
Scaffold new Aptos projects using . This is the mandatory first step when a user wants to
build any new Aptos app, dApp, or project — regardless of how they phrase it.
npx create-aptos-dapp使用搭建新的Aptos项目脚手架。当用户想要构建任何新的Aptos应用、dApp或项目时,无论用户如何表述,这都是强制的第一步。
npx create-aptos-dappALWAYS
必须遵守
- Use to scaffold — NEVER create projects from scratch manually
npx create-aptos-dapp - Ask the user about project type, framework, and network before scaffolding
- Verify is in
.envbefore any git operations.gitignore - Use the same network for both and
create-aptos-dappaptos init - Follow the full Build a dApp workflow after scaffolding (contracts, tests, audit, deploy, frontend)
- 使用搭建脚手架——绝对不要手动从零开始创建项目
npx create-aptos-dapp - 搭建前询问用户项目类型、框架和网络
- 执行任何git操作前,确认已加入
.env.gitignore - 和
create-aptos-dapp使用相同的网络aptos init - 搭建完成后遵循完整的dApp构建工作流(合约、测试、审计、部署、前端)
NEVER
禁止操作
- Skip scaffolding — even for "simple" projects, always start with
create-aptos-dapp - Create project structure manually — the boilerplate template handles this
- Display or read private keys — use as placeholder
"0x..." - Run or
git add .without first verifyinggit add -Ais in.env.gitignore
- 跳过脚手架搭建——即使是“简单”项目,也始终要从开始
create-aptos-dapp - 手动创建项目结构——脚手架模板已经处理好了这部分
- 展示或读取私钥——使用作为占位符
"0x..." - 未验证已加入
.env就执行.gitignore或git add .git add -A
Decision Tree
决策树
Before running the scaffold command, gather these inputs from the user:
在运行脚手架命令前,从用户处收集以下信息:
1. Project Name
1. 项目名称
Derive from the user's description or ask directly. Use kebab-case (e.g., , ).
habit-trackernft-marketplace从用户的描述中提取,或直接询问用户。使用短横线命名法(例如:、)。
habit-trackernft-marketplace2. Project Type
2. 项目类型
| Option | When to Use |
|---|---|
| Fullstack (default) | User wants a frontend + smart contracts |
| Contract-only | User only wants Move smart contracts (no frontend) |
| 选项 | 适用场景 |
|---|---|
| 全栈(默认) | 用户需要前端 + 智能合约 |
| 仅合约 | 用户只需要Move智能合约(无前端) |
3. Framework (fullstack only)
3. 框架(仅全栈项目需要)
| Option | When to Use |
|---|---|
| Vite (default) | Default choice, lighter setup |
| Next.js | User asks for Next.js or SSR |
| 选项 | 适用场景 |
|---|---|
| Vite(默认) | 默认选择,更轻量的配置 |
| Next.js | 用户要求使用Next.js或SSR |
4. Network
4. 网络
| Option | When to Use |
|---|---|
| devnet (default) | Development and testing |
| testnet | Pre-production, user explicitly asks |
| mainnet | Production, user explicitly asks |
| 选项 | 适用场景 |
|---|---|
| devnet(默认) | 开发和测试阶段 |
| testnet | 预生产环境,用户明确要求时使用 |
| mainnet | 生产环境,用户明确要求时使用 |
5. API Key (optional)
5. API密钥(可选)
Ask if the user has a Geomi API key. It's optional for devnet but recommended for testnet/mainnet to avoid rate limits.
Get one at https://geomi.dev (create project -> API Resource -> copy key).
询问用户是否有Geomi API密钥。devnet环境下可选,但testnet/mainnet环境推荐使用以避免触发速率限制。可在https://geomi.dev获取密钥(创建项目 -> API资源 -> 复制密钥)。
Scaffolding Commands
脚手架命令
bash
undefinedbash
undefinedFullstack dApp with Vite (frontend + contracts)
基于Vite的全栈dApp(前端 + 合约)
npx create-aptos-dapp <project-name>
--project-type fullstack
--template boilerplate-template
--framework vite
--network <network>
--project-type fullstack
--template boilerplate-template
--framework vite
--network <network>
npx create-aptos-dapp <project-name>
--project-type fullstack
--template boilerplate-template
--framework vite
--network <network>
--project-type fullstack
--template boilerplate-template
--framework vite
--network <network>
Fullstack dApp with Next.js
基于Next.js的全栈dApp
npx create-aptos-dapp <project-name>
--project-type fullstack
--template boilerplate-template
--framework nextjs
--network <network>
--project-type fullstack
--template boilerplate-template
--framework nextjs
--network <network>
npx create-aptos-dapp <project-name>
--project-type fullstack
--template boilerplate-template
--framework nextjs
--network <network>
--project-type fullstack
--template boilerplate-template
--framework nextjs
--network <network>
Contract-only (Move project)
仅合约(Move项目)
npx create-aptos-dapp <project-name>
--project-type move
--network <network>
--project-type move
--network <network>
**Optional flags:**
- `--api-key <key>` — Pass a Geomi API key during scaffolding
- `--use-surf` — Enable Surf for type-safe contract interactions
---npx create-aptos-dapp <project-name>
--project-type move
--network <network>
--project-type move
--network <network>
**可选参数:**
- `--api-key <key>` — 搭建时传入Geomi API密钥
- `--use-surf` — 启用Surf实现类型安全的合约交互
---Post-Scaffold Checklist
脚手架搭建后检查清单
After scaffolding, complete these steps in order:
cd <project-name>- Verify is in
.envbefore any git operations.gitignore - Run (use the same network as above)
aptos init --network <network> --assume-yes - Verify:
npm run move:compile && npm run move:test git init && git add . && git commit -m "Initial commit"
搭建完成后,按顺序完成以下步骤:
cd <project-name>- 执行任何git操作前确认已加入
.env.gitignore - 运行(使用和上方相同的网络)
aptos init --network <network> --assume-yes - 验证编译和测试:
npm run move:compile && npm run move:test git init && git add . && git commit -m "Initial commit"
Build a dApp Workflow
dApp构建工作流
ALWAYS follow this workflow when the user wants to build a new Aptos app, dApp, or project. This applies regardless
of how the user phrases it ("build me a ...", "create a ...", "make a ...", "I want to build ...").
- -> scaffold with
/create-aptos-project(this skill — NEVER skip)npx create-aptos-dapp - -> write Move modules
/write-contracts - -> create test suite, verify 100% coverage
/generate-tests - -> audit before deployment
/security-audit - -> deploy contract to specified network
/deploy-contracts - -> orchestrates frontend integration (routes to ts-sdk-client, ts-sdk-transactions, ts-sdk-view-and-query, ts-sdk-wallet-adapter as needed)
/use-ts-sdk
当用户想要构建新的Aptos应用、dApp或项目时,必须遵循此工作流,无论用户如何表述("build me a ...", "create a ...", "make a ...", "I want to build ...")。
- -> 使用
/create-aptos-project搭建脚手架(本技能——绝对不要跳过)npx create-aptos-dapp - -> 编写Move模块
/write-contracts - -> 创建测试套件,确认100%覆盖率
/generate-tests - -> 部署前安全审计
/security-audit - -> 将合约部署到指定网络
/deploy-contracts - -> 协调前端集成(根据需要路由到ts-sdk-client、ts-sdk-transactions、ts-sdk-view-and-query、ts-sdk-wallet-adapter)
/use-ts-sdk
What the Boilerplate Includes
模板包含内容
Fullstack Template
全栈模板
- — Move smart contract with
contract/and starter moduleMove.toml - — React app with Aptos wallet adapter pre-configured
frontend/ - — Scripts for
package.json,move:compile,move:test,move:publish,devbuild - — Environment variables for network, API key, and publisher account
.env
- — 包含
contract/和入门模块的Move智能合约Move.toml - — 预配置了Aptos钱包适配器的React应用
frontend/ - — 包含
package.json、move:compile、move:test、move:publish、dev等脚本build - — 存储网络、API密钥和发布者账户的环境变量
.env
Contract-Only Template
仅合约模板
- — Move smart contract with
contract/and starter moduleMove.toml - — Scripts for
package.json,move:compile,move:testmove:publish - — Environment variables for network and publisher account
.env
- — 包含
contract/和入门模块的Move智能合约Move.toml - — 包含
package.json、move:compile、move:test等脚本move:publish - — 存储网络和发布者账户的环境变量
.env
Troubleshooting
故障排查
npx create-aptos-dapp
command not found
npx create-aptos-dapp提示npx create-aptos-dapp
命令不存在
npx create-aptos-dappbash
undefinedbash
undefinedAuto-confirm the npx package install prompt
自动确认npx包安装提示
npx --yes create-aptos-dapp <project-name> ...
If that still fails, verify Node.js and npm are installed (`node -v && npm -v`).npx --yes create-aptos-dapp <project-name> ...
如果仍然报错,确认Node.js和npm已安装(执行`node -v && npm -v`查看版本)。Compile failures after scaffold
脚手架搭建后编译失败
- Check has correct named addresses
contract/Move.toml - Run if not done
aptos init --network <network> --assume-yes - Verify is set to
my_addrin"_"section[addresses]
- 检查中的命名地址是否正确
contract/Move.toml - 如果未执行过,先运行该命令
aptos init --network <network> --assume-yes - 确认部分的
[addresses]设置为my_addr"_"
Named address errors
命名地址错误
The boilerplate uses which gets resolved from at compile time. Ensure
is set in (populated by ).
my_addr = "_".envVITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS.envaptos init模板默认使用,会在编译时从中解析取值。确保中设置了(由自动填充)。
my_addr = "_".env.envVITE_MODULE_PUBLISHER_ACCOUNT_ADDRESSaptos init