Scaffold Project Skill
项目脚手架搭建Skill
This skill creates new Aptos dApp projects by bootstrapping directly from official templates using
. This
approach provides clean copies of production-ready templates without git history.
本Skill通过
直接从官方模板引导创建新的Aptos dApp项目。这种方式可以获取生产就绪模板的干净副本,且不包含Git历史记录。
| Type | Template | Use Case |
|---|
| Fullstack dApp | | Frontend + smart contracts |
| Contract-only | contract-boilerplate-template
| Smart contracts without frontend |
| 类型 | 模板名称 | 使用场景 |
|---|
| 全栈dApp | | 前端+智能合约 |
| 仅合约 | contract-boilerplate-template
| 不含前端的智能合约 |
Fullstack dApp Scaffolding
全栈dApp搭建步骤
Step 1: Bootstrap with degit
步骤1:使用degit引导
Bootstrap fullstack template (no git history)
引导全栈模板(无Git历史)
npx degit aptos-labs/create-aptos-dapp/templates/boilerplate-template my-dapp
cd my-dapp
> **Note:** The degit command references a specific template path in the aptos-labs/create-aptos-dapp repository. If you
> encounter errors, verify the template path exists at
> https://github.com/aptos-labs/create-aptos-dapp/tree/main/templates
npx degit aptos-labs/create-aptos-dapp/templates/boilerplate-template my-dapp
cd my-dapp
> **注意:** degit命令引用了aptos-labs/create-aptos-dapp仓库中的特定模板路径。如果遇到错误,请验证模板路径是否存在于https://github.com/aptos-labs/create-aptos-dapp/tree/main/templates
Step 2: Configure Environment
步骤2:配置环境
Create file with the following variables:
cat > .env << 'EOF'
PROJECT_NAME=my-dapp
VITE_APP_NETWORK=devnet
VITE_APTOS_API_KEY=""
VITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS=
cat > .env << 'EOF'
PROJECT_NAME=my-dapp
VITE_APP_NETWORK=devnet
VITE_APTOS_API_KEY=""
VITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS=
This is the module publisher account's private key.
这是模块发布者账户的私钥。
Be cautious about who you share it with, and ensure it is not exposed when deploying your dApp.
请谨慎分享,确保在部署dApp时不会泄露。
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY=
EOF
**Configure the values:**
- `PROJECT_NAME` - Your project name
- `VITE_APP_NETWORK` - Network to use (`devnet`, `testnet`, or `mainnet`)
- `VITE_APTOS_API_KEY` - Optional API key from Aptos Labs
- `VITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS` - Your deployer account address (set after `aptos init`)
- `VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY` - Your deployer private key (from `~/.aptos/config.yaml`)
**⚠️ CRITICAL: Ensure `.env` is in `.gitignore`:**
```bash
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY=
EOF
**配置变量值:**
- `PROJECT_NAME` - 你的项目名称
- `VITE_APP_NETWORK` - 使用的网络(`devnet`、`testnet`或`mainnet`)
- `VITE_APTOS_API_KEY` - 可选的Aptos Labs提供的API密钥
- `VITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS` - 你的部署者账户地址(执行`aptos init`后设置)
- `VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY` - 你的部署者私钥(来自`~/.aptos/config.yaml`)
**⚠️ 重要:确保`.env`已添加到`.gitignore`中:**
```bash
Verify .env is gitignored (should already be there)
验证.env是否已被Git忽略(应该已存在)
grep -q "^.env$" .gitignore || echo ".env" >> .gitignore
grep -q "^.env$" .gitignore || echo ".env" >> .gitignore
Step 3: Update Move.toml
步骤3:更新Move.toml
Edit
with your project name:
toml
[package]
name = "my_dapp" # Your project name
version = "1.0.0"
authors = []
[addresses]
my_dapp_addr = "_" # Will be set during deployment
[dev-addresses]
my_dapp_addr = "0xCAFE" # For testing
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-framework.git", rev = "mainnet", subdir = "aptos-framework" }
toml
[package]
name = "my_dapp" # 你的项目名称
version = "1.0.0"
authors = []
[addresses]
my_dapp_addr = "_" # 将在部署时设置
[dev-addresses]
my_dapp_addr = "0xCAFE" # 用于测试
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-framework.git", rev = "mainnet", subdir = "aptos-framework" }
Step 4: Install Dependencies
步骤4:安装依赖
Step 5: Initialize Git
步骤5:初始化Git
bash
git init
git add .
git commit -m "Initial commit: Bootstrap Aptos dApp from boilerplate template"
bash
git init
git add .
git commit -m "Initial commit: Bootstrap Aptos dApp from boilerplate template"
Step 6: Verify Setup
步骤6:验证配置
Compile Move contracts
编译Move合约
Start frontend development server
启动前端开发服务器
Fullstack Project Structure
全栈项目结构
my-dapp/
├── frontend/
│ ├── components/ # React UI components
│ ├── entry-functions/ # Write operations (transactions)
│ ├── view-functions/ # Read operations (queries)
│ ├── lib/ # Shared libraries (wallet, aptos client)
│ ├── utils/ # Helpers
│ ├── App.tsx
│ ├── constants.ts
│ └── main.tsx
├── contract/
│ ├── sources/ # Move modules
│ ├── tests/ # Move tests
│ └── Move.toml
├── scripts/move/ # Deployment scripts
├── package.json # npm scripts for move:compile, move:test, etc.
├── .env # Environment variables (NEVER commit!)
├── .gitignore # Must include .env
└── [config files] # vite, tailwind, typescript, etc.
my-dapp/
├── frontend/
│ ├── components/ # React UI组件
│ ├── entry-functions/ # 写入操作(交易)
│ ├── view-functions/ # 读取操作(查询)
│ ├── lib/ # 共享库(钱包、Aptos客户端)
│ ├── utils/ # 工具函数
│ ├── App.tsx
│ ├── constants.ts
│ └── main.tsx
├── contract/
│ ├── sources/ # Move模块
│ ├── tests/ # Move测试
│ └── Move.toml
├── scripts/move/ # 部署脚本
├── package.json # npm脚本,如move:compile、move:test等
├── .env # 环境变量(绝对不要提交!)
├── .gitignore # 必须包含.env
└── [配置文件] # vite、tailwind、typescript等
Key Directories Explained
关键目录说明
| Directory | Purpose |
|---|
frontend/entry-functions/
| Transaction payloads for write operations |
| Queries for read operations |
| Aptos client and wallet provider setup |
| Move smart contract modules |
| Deployment and utility scripts |
| 目录 | 用途 |
|---|
frontend/entry-functions/
| 写入操作的交易负载 |
| 读取操作的查询 |
| Aptos客户端和钱包提供者配置 |
| Move智能合约模块 |
| 部署和实用脚本 |
Contract-Only Scaffolding
仅合约项目搭建步骤
Step 1: Bootstrap with degit
步骤1:使用degit引导
Bootstrap contract-only template
引导仅合约模板
npx degit aptos-labs/create-aptos-dapp/templates/contract-boilerplate-template my-contract
cd my-contract
npx degit aptos-labs/create-aptos-dapp/templates/contract-boilerplate-template my-contract
cd my-contract
Step 2: Configure Environment
步骤2:配置环境
Create file with the following variables:
cat > .env << 'EOF'
PROJECT_NAME=my-contract
VITE_APP_NETWORK=devnet
VITE_APTOS_API_KEY=""
VITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS=
cat > .env << 'EOF'
PROJECT_NAME=my-contract
VITE_APP_NETWORK=devnet
VITE_APTOS_API_KEY=""
VITE_MODULE_PUBLISHER_ACCOUNT_ADDRESS=
This is the module publisher account's private key.
这是模块发布者账户的私钥。
Be cautious about who you share it with, and ensure it is not exposed when deploying your dApp.
请谨慎分享,确保在部署dApp时不会泄露。
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY=
EOF
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY=
EOF
Ensure .env is gitignored
确保.env已被Git忽略
grep -q "^.env$" .gitignore || echo ".env" >> .gitignore
grep -q "^.env$" .gitignore || echo ".env" >> .gitignore
Step 3: Update Move.toml
步骤3:更新Move.toml
toml
[package]
name = "my_contract"
version = "1.0.0"
[addresses]
my_contract_addr = "_"
[dev-addresses]
my_contract_addr = "0xCAFE"
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-framework.git", rev = "mainnet", subdir = "aptos-framework" }
toml
[package]
name = "my_contract"
version = "1.0.0"
[addresses]
my_contract_addr = "_"
[dev-addresses]
my_contract_addr = "0xCAFE"
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-framework.git", rev = "mainnet", subdir = "aptos-framework" }
Step 4: Install & Verify
步骤4:安装依赖并验证
Step 5: Initialize Git
步骤5:初始化Git
bash
git init
git add .
git commit -m "Initial commit: Bootstrap Aptos contract from template"
bash
git init
git add .
git commit -m "Initial commit: Bootstrap Aptos contract from template"
Contract-Only Project Structure
仅合约项目结构
my-contract/
├── contract/
│ ├── sources/ # Move modules
│ ├── tests/ # Move tests
│ └── Move.toml
├── scripts/move/ # Deployment scripts
├── package.json # npm scripts
├── .env # Environment variables (NEVER commit!)
└── .gitignore # Must include .env
my-contract/
├── contract/
│ ├── sources/ # Move模块
│ ├── tests/ # Move测试
│ └── Move.toml
├── scripts/move/ # 部署脚本
├── package.json # npm脚本
├── .env # 环境变量(绝对不要提交!)
└── .gitignore # 必须包含.env
Available npm Scripts
可用的npm脚本
Both templates include these npm scripts:
npm run move:compile # Compile Move contracts
npm run move:test # Run Move tests
npm run move:publish # Publish to network (uses .env)
npm run move:compile # 编译Move合约
npm run move:test # 运行Move测试
npm run move:publish # 发布到网络(使用.env中的配置)
npm run dev # Start frontend dev server
npm run build # Build for production
npm run dev # 启动前端开发服务器
npm run build # 生产环境构建
Alternative: Manual Move-Only Setup
替代方案:手动搭建仅Move项目
For pure Move development without the npm wrapper, use
:
如果不需要npm包装器,仅进行纯Move开发,可以使用
:
Initialize Move project
初始化Move项目
aptos move init --name my_module
aptos move init --name my_module
Configure Move.toml manually
手动配置Move.toml
Create sources/ and tests/ directories
创建sources/和tests/目录
See the "Move-Only Reference" section below for detailed manual setup.
---
请查看下方的“仅Move参考”部分获取详细的手动配置步骤。
---
Quick Reference Commands
快速参考命令
Fullstack dApp (Recommended)
全栈dApp(推荐)
npx degit aptos-labs/create-aptos-dapp/templates/boilerplate-template my-dapp
cd my-dapp
npm install
git init
npx degit aptos-labs/create-aptos-dapp/templates/boilerplate-template my-dapp
cd my-dapp
npm install
git init
Then create .env manually (see Step 2 above) - NEVER commit .env!
然后手动创建.env文件(参考步骤2)——绝对不要提交.env!
npx degit aptos-labs/create-aptos-dapp/templates/contract-boilerplate-template my-contract
cd my-contract
npm install
git init
npx degit aptos-labs/create-aptos-dapp/templates/contract-boilerplate-template my-contract
cd my-contract
npm install
git init
Then create .env manually (see Step 2 above) - NEVER commit .env!
然后手动创建.env文件(参考步骤2)——绝对不要提交.env!
Post-Scaffolding Checklist
搭建后检查清单
After bootstrapping, complete these steps:
⚠️ Before committing: Double-check that
is NOT staged (
)
Move-Only Reference (Manual Setup)
仅Move参考(手动配置)
For cases where you need manual Move setup without templates:
bash
aptos move init --name my_module
bash
aptos move init --name my_module
Configure Move.toml
配置Move.toml
toml
[package]
name = "my_module"
version = "1.0.0"
[addresses]
my_addr = "_"
[dev-addresses]
my_addr = "0xCAFE"
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-framework.git", rev = "mainnet", subdir = "aptos-framework" }
toml
[package]
name = "my_module"
version = "1.0.0"
[addresses]
my_addr = "_"
[dev-addresses]
my_addr = "0xCAFE"
[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-framework.git", rev = "mainnet", subdir = "aptos-framework" }
move
// sources/main.move
module my_addr::main {
use std::signer;
struct Counter has key {
value: u64
}
public entry fun init_counter(account: &signer) {
move_to(account, Counter { value: 0 });
}
public entry fun increment(account: &signer) acquires Counter {
let counter = borrow_global_mut<Counter>(signer::address_of(account));
counter.value = counter.value + 1;
}
}
move
// sources/main.move
module my_addr::main {
use std::signer;
struct Counter has key {
value: u64
}
public entry fun init_counter(account: &signer) {
move_to(account, Counter { value: 0 });
}
public entry fun increment(account: &signer) acquires Counter {
let counter = borrow_global_mut<Counter>(signer::address_of(account));
counter.value = counter.value + 1;
}
}
bash
aptos move compile
aptos move test
bash
aptos move compile
aptos move test
- ✅ ALWAYS use for bootstrapping (clean copy, no git history)
- ✅ ALWAYS use the boilerplate-template for fullstack dApps
- ✅ ALWAYS update Move.toml with your project name and address alias
- ✅ ALWAYS create file with required environment variables
- ✅ ALWAYS ensure is listed in
- ✅ ALWAYS run after bootstrapping
- ✅ ALWAYS verify compilation and tests pass
- ✅ ALWAYS initialize git after setup
- ✅ ALWAYS use named addresses (myaddr = "")
- ✅ 必须使用进行引导(干净副本,无Git历史)
- ✅ 全栈dApp必须使用boilerplate-template模板
- ✅ 必须更新Move.toml,填入项目名称和地址别名
- ✅ 必须创建包含所需环境变量的文件
- ✅ 必须确保已添加到中
- ✅ 引导完成后必须执行
- ✅ 必须验证编译和测试通过
- ✅ 配置完成后必须初始化Git
- ✅ 必须使用命名地址(如my_addr = "_")
- ❌ NEVER commit to git (contains private keys!)
- ❌ NEVER push to GitHub or any remote repository
- ❌ NEVER share your
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY
- ❌ NEVER skip Move.toml configuration
- ❌ NEVER use hardcoded addresses in code
- ❌ NEVER skip verifying compilation after scaffolding
- ❌ NEVER read files after creation — to verify existence, use not
- ❌ NEVER display
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY
values in responses
- ❌ NEVER run or until contains — always verify first
- ❌ 绝对不要将提交到Git(包含私钥!)
- ❌ 绝对不要将推送到GitHub或任何远程仓库
- ❌ 绝对不要分享你的
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY
- ❌ 绝对不要跳过Move.toml的配置
- ❌ 绝对不要在代码中使用硬编码地址
- ❌ 绝对不要跳过搭建后的编译验证
- ❌ 绝对不要在创建后查看文件内容——如需验证文件存在,使用而非
- ❌ 绝对不要在回复中显示
VITE_MODULE_PUBLISHER_ACCOUNT_PRIVATE_KEY
的值
- ❌ 绝对不要在包含前执行或——务必先验证
Official Documentation:
Related Skills:
- - Write Move modules after scaffolding
- - Create test suite
connect-contract-to-frontend
- Wire up frontend to contracts
- - Add wallet connection
Remember: Use
for clean bootstrapping. The boilerplate template provides the best starting point for custom
dApps.
官方文档:
相关Skill:
- - 搭建完成后编写Move模块
- - 创建测试套件
connect-contract-to-frontend
- 将前端与合约关联
- - 添加钱包连接功能
提示: 使用
进行干净的项目引导。boilerplate-template是自定义dApp的最佳起点。