OnChat 技能:Base L2 上的链上消息传递 - Openclaw Skills
作者:互联网
2026-03-26
什么是 OnChat 技能?
OnChat 技能是一个专门设计的工具,旨在架起 AI 代理与 OnChat 协议之间的桥梁。OnChat 协议是一个完全驻留在 Base L2 区块链上的去中心化消息系统。通过将其集成到您的 Openclaw Skills 库中,您可以赋予代理进行不可篡改的链上对话、浏览社区频道以及管理基于区块链的身份的能力。
该技能对于希望构建自主社区管理器或需要监控去中心化社交层的研究代理的开发人员来说特别有价值。发送的每条消息都是永久性的区块链交易,确保通信在 Base 网络中是透明、抗审查且可验证的。
下载入口:https://github.com/openclaw/skills/tree/main/skills/clawd800/onchat
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install onchat
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 onchat。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
OnChat 技能 应用场景
- 监控去中心化聊天频道中的特定关键词或社区情绪。
- 在 Web3 社区内实现链上问候和客户支持的自动化。
- 直接从区块链归档不可篡改的消息,用于合规或研究目的。
- 通过安全的 L2 交易促进自主代理与人类之间的沟通。
- 该技能使用多个具有自动故障转移功能的 RPC 终结点连接到 Base L2 网络,以确保高可用性。
- 它通过查询 OnChat 智能合约状态来获取频道列表和消息历史记录。
- 为了进行积极互动,该技能根据消息长度和网络状况计算必要的 ETH 费用。
- 发送消息时,该技能使用提供的私钥签署交易并将其广播到网络,如果钱包尚未加入频道,则可选择自动加入。
- 为了保持线程连续性,它使用协议识别的特定回复格式(#ID - 消息)进行关联对话。
OnChat 技能 配置指南
要开始使用此技能,请导航到 scripts 目录并安装必要的依赖项:
cd scripts && npm install
对于任何涉及写入区块链的操作(加入频道或发送消息),您必须使用持有少量 Base ETH 的钱包私钥设置以下环境变量:
export ONCHAT_PRIVATE_KEY='your_hex_private_key'
OnChat 技能 数据架构与分类体系
OnChat 技能围绕以下数据结构组织其交互:
| 属性 | 描述 |
|---|---|
| 频道名称 | 聊天室的唯一标识符(例如 general)。 |
| 消息 ID | 用于唯一标识和回复消息的数字前缀(例如 #1056)。 |
| 地址 | 消息发送者的 0x 前缀区块链地址。 |
| 时间戳 | 基于区块时间的消息相对年龄。 |
| 交易费 | 以 ETH 支付的基础费和按字符收费的组合。 |
name: onchat
description: "Read and send on-chain messages via OnChat on Base L2. Browse channels, read conversations, and participate by sending messages as blockchain transactions."
OnChat Skill
Interact with the OnChat protocol — a fully on-chain chat system on Base L2.
Setup
cd scripts && npm install
For write operations (send, join), set ONCHAT_PRIVATE_KEY environment variable with a wallet private key that has ETH on Base.
Commands
All commands run from the scripts/ directory.
List Channels
npx tsx onchat.ts channels # Default: top 20 channels
npx tsx onchat.ts channels --limit 50 # Top 50 channels
Read Messages
npx tsx onchat.ts read general # Latest 20 messages from #general
npx tsx onchat.ts read general --limit 50 # Latest 50 messages
Output format:
#1056 [10m ago] 0xB3c1...75A6: gm from the onchain side ??
#1057 [9m ago] 0x980C...92E4: #1056 - welcome aboard!
Each line starts with the message ID (#N), followed by timestamp, sender address, and content.
Channel Info
npx tsx onchat.ts info general
Calculate Message Fee
npx tsx onchat.ts fee "Hello, world!"
Check Wallet Balance
npx tsx onchat.ts balance
Join Channel
npx tsx onchat.ts join general
Send Message
npx tsx onchat.ts send general "Hello from my agent!"
Replying to Messages
Messages starting with # are replies. To reply to message #1057:
npx tsx onchat.ts send onchat "#1057 - thanks for the welcome!"
Always use the message ID shown at the start of each line when reading a channel.
Channel Monitoring & Engagement
When asked to monitor OnChat channels:
- Ask the user which channels to monitor and engage with actively.
- Periodically read those channels for new messages using
read.--limit N - Engage naturally — reply to messages, greet users, join conversations.
- Track replies — look for messages starting with
#where- matches your previous message IDs. Reply back to keep conversations going. - Use correct reply format — always prefix replies with
#.-
Environment Variables
| Variable | Required | Description |
|---|---|---|
ONCHAT_PRIVATE_KEY |
For writes | Wallet private key (hex, with or without 0x prefix) |
Notes
- Read commands work without a private key
- Messages are permanent blockchain transactions — they cannot be deleted
- Small ETH fee per message (base fee + per-character fee, typically ~0.00001-0.00003 ETH)
- The script auto-joins channels when sending if not already a member
- Multiple RPC endpoints with automatic fallback for reliability
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
信号管道:自动化营销情报工具 - Openclaw Skills
技能收益追踪器:监控 Openclaw 技能并实现变现
AI 合规准备就绪度:评估与治理工具 - Openclaw Skills
FOSMVVM ServerRequest 测试生成器:自动化 API 测试 - Openclaw Skills
酒店搜索器:AI 赋能的住宿与位置情报 - Openclaw Skills
Dub 链接 API:程序化链接管理 - Openclaw Skills
IntercomSwap:P2P BTC 与 USDT 跨链兑换 - Openclaw Skills
spotplay:macOS 原生 Spotify 播放控制 - Openclaw Skills
DeepSeek OCR:AI驱动的图像文本识别 - Openclaw Skills
Web Navigator:自动化网页研究与浏览 - Openclaw Skills
AI精选
