Rue Chialisp:类型安全的智能合约开发 - Openclaw Skills
作者:互联网
2026-04-16
什么是 Rue Chialisp?
Rue Chialisp 是专为 Chia 生态系统开发者设计的专业工具。它利用 Rue(一种高级、类型安全的语言),通过将复杂的区块链谜题编译成 Chia Lisp 虚拟机 (CLVM) 字节码来简化其创建过程。通过在 Openclaw Skills 中使用此集成,开发者可以将硬币花费条件的自然语言描述转换为稳健、生产就绪的智能合约。
该技能弥合了高级逻辑与低级字节码之间的差距,为定义时间锁、多重签名要求和托管协议等条件提供了结构化环境。无论您是在构建原子交换还是定期支付系统,该工具都能确保类型安全,并提供即时模拟功能,以便在链上部署前验证合约行为。
下载入口:https://github.com/openclaw/skills/tree/main/skills/koba42corp/rue-chialisp
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install rue-chialisp
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 rue-chialisp。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
Rue Chialisp 应用场景
- 实现仅在特定区块高度后释放资金的时间锁交易。
- 开发需要多个加密签名的安全 N-of-M 多重签名钱包。
- 创建带有集成仲裁逻辑的自动化托管服务,实现安全的点对点交易。
- 为 NFT 市场或服务提供商构建版税和分账支付系统。
- 为跨链或无信任资产交换生成原子交换 (HTLC) 合约。
- 在 Openclaw Skills 中使用自然语言提示快速原型化自定义硬币花费条件。
- 分析用户的自然语言请求,识别多重签名或撤回等特定的区块链逻辑模式。
- 使用内部 rue-init 脚本初始化新项目结构,以设置开发环境。
- 根据识别的花费条件和用户提供的参数生成类型安全的 Rue 源代码。
- 使用 rue build 命令将 Rue 源代码编译为 CLVM 字节码。
- 使用 brun 工具通过测试输入模拟生成的谜题执行,以验证生成的条件。
Rue Chialisp 配置指南
要开始使用此技能,请运行以下命令确保您的环境已就绪:
# 验证是否已安装必要的依赖项
scripts/rue-check.sh
# 初始化新的 Rue 项目
scripts/rue-init.sh my-project-name
初始化后,导航到项目目录并使用 rue build 将您的谜题编译为 CLVM。该过程已为 Openclaw Skills 用户简化,以确保快速迭代。
Rue Chialisp 数据架构与分类体系
该技能通过结构化文件系统和特定数据类型组织智能合约数据和元数据:
| 组件 | 描述 |
|---|---|
| .rue 文件 | 包含谜题逻辑和类型定义的源代码。 |
| CLVM 字节码 | 准备好用于 Chia 区块链部署的编译输出。 |
| 类型 | 支持 Int、Bool、Bytes32、PublicKey 和 List |
| 条件 | 标准化的 CLVM 输出,如 CreateCoin (51) 和 AggSigMe (50)。 |
与 Openclaw Skills 的集成确保每个谜题都映射到清晰的元数据分类,以便于检索和审计。
name: rue-chialisp
version: 1.0.0
description: Create Chia blockchain puzzles using Rue, a type-safe language that compiles to CLVM. Use for smart contract development, custom puzzle creation, or when user says "create a coin that...", "build a puzzle", "chialisp", "rue", "timelock", "multisig", "escrow", "atomic swap", or describes coin spending conditions.
Rue Chialisp Skill
Build type-safe Chia puzzles using Rue. Compile to CLVM bytecode for on-chain deployment.
Setup
# Check dependencies
scripts/rue-check.sh
# Initialize project
scripts/rue-init.sh my-project
Quick Build
cd my-project
rue build # Compile all puzzles
rue build puzzles/x.rue # Compile one
brun "$CLVM" "(args)" # Simulate execution
Natural Language → Puzzle
When user describes a puzzle in plain language, map to these patterns:
| User Says | Pattern | Example File |
|---|---|---|
| "only spend after block X" | Timelock | examples/timelock.rue |
| "requires N signatures" | Multisig | examples/multisig.rue |
| "burn X%" | Partial Burn | examples/burn_10_percent.rue |
| "split payment" | Royalty | examples/royalty.rue |
| "escrow with arbiter" | Escrow | examples/escrow.rue |
| "atomic swap / HTLC" | Atomic Swap | examples/atomic_swap.rue |
| "reversible / clawback" | Clawback | examples/clawback.rue |
| "spending limit" | Rate Limited | examples/rate_limited.rue |
| "recurring payment" | Subscription | examples/subscription.rue |
| "password protected" | Password | examples/password_puzzle.rue |
| "signature required" | Signature | examples/sig_puzzle.rue |
Core Syntax
fn main(curried_arg: Type, solution_arg: Type) -> List {
assert condition;
let x = expression;
if cond { a } else { b }
[item1, item2, ...rest]
}
Types
| Type | Description |
|---|---|
Int |
Signed integer |
Bool |
true/false |
Bytes32 |
32-byte hash |
PublicKey |
BLS G1 (48 bytes) |
List |
Nil-terminated list |
Condition |
CLVM condition |
Key Conditions
| Condition | Opcode | Purpose |
|---|---|---|
CreateCoin { puzzle_hash, amount, memos } |
51 | Create output |
AggSigMe { public_key, message } |
50 | Require signature |
AssertHeightAbsolute { height } |
83 | Min block height |
AssertBeforeHeightAbsolute { height } |
87 | Max block height |
AssertMyAmount { amount } |
73 | Verify coin value |
ReserveFee { amount } |
52 | Transaction fee |
See references/conditions.md for full list (30+ conditions).
Built-in Functions
| Function | Use |
|---|---|
sha256(data) |
Hash data |
tree_hash(value) |
CLVM tree hash |
coinid(parent, puzzle_hash, amount) |
Compute coin ID |
Example: Timelock
fn main(unlock_height: Int, dest: Bytes32, amount: Int) -> List {
let wait = AssertHeightAbsolute { height: unlock_height };
let output = CreateCoin { puzzle_hash: dest, amount, memos: nil };
[wait, output]
}
Example: 2-of-2 Multisig
fn main(pk1: PublicKey, pk2: PublicKey, conditions: List) -> List {
let msg = tree_hash(conditions);
let sig1 = AggSigMe { public_key: pk1, message: msg };
let sig2 = AggSigMe { public_key: pk2, message: msg };
[sig1, sig2, ...conditions]
}
Simulation
# Compile
CLVM=$(rue build puzzles/my_puzzle.rue 2>&1 | grep -v Warning | head -1)
# Execute with test inputs
brun "$CLVM" "(arg1 arg2 arg3)"
# Output is list of conditions: ((51 ) (83 ) ...)
Security Notes
- Password puzzles are educational only — use signatures for real value
- Always validate input types with
assert value is Type - Use
tree_hash(conditions)as signature message to bind signatures to outputs
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
Minecraft 3D 建造计划生成器:AI 场景架构师 - Openclaw Skills
Scholar Search:自动化文献搜索与研究简报 - Openclaw Skills
issue-to-pr: 自动化 GitHub Issue 修复与 PR 生成 - Openclaw Skills
接班交班总结器:临床 EHR 自动化 - Openclaw Skills
Teacher AI 备课专家:K-12 自动化教案设计 - Openclaw Skills
专利权利要求映射器:生物技术与制药 IP 分析 - Openclaw Skills
生成 Tesla 车身改色膜:用于 3D 显示的 AI 图像生成 - Openclaw Skills
Taiwan MD:面向台湾的 AI 原生开放知识库 - Openclaw Skills
自学习与迭代演进:AI Agent 成长框架 - Openclaw Skills
HIPC Config Manager: 安全的 API 凭据处理器 - Openclaw Skills
AI精选
