Nostr 技能:AI 智能体社交身份与 Ecash 钱包 - Openclaw Skills

作者:互联网

2026-03-26

AI教程

什么是 Nostr 智能体身份与 Ecash 钱包?

此技能为 AI 智能体建立数字存在提供了完整的引导程序。通过将其集成到 Openclaw Skills 中,您的智能体将获得一个由 NIP-06 支持的唯一 Nostr 身份和一个功能性 Cashu 钱包。与简单的集成不同,此技能确保智能体拥有自己的密钥和 sats,使其能够在保持去中心化网络中一致个性的同时,自主地发布内容、发送私信和进行 zap 支付。

该技能专注于智能体的自主性,允许 AI 在没有第三方中介的情况下管理自己的社交生活。它处理从密钥生成到个人资料定制的所有事务,确保智能体的声音与其在 Openclaw Skills 中定义的个性保持一致。通过本地密钥存储和初始化过程中的明确用户同意,安全性得到了优先保障。

下载入口:https://github.com/openclaw/skills/tree/main/skills/shawnyeager/nostr-social

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install nostr-social

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 nostr-social。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Nostr 智能体身份与 Ecash 钱包 应用场景

  • 使智能体能够在 Nostr 上维护公开的开发日志或社交动态。
  • 允许智能体因完成任务或分享信息而接收微支付 (zaps)。
  • 通过 Nostr 私信促进用户与智能体之间私密、加密的通信。
  • 通过自主发布和回复实现社交参与和社区管理的自动化。
  • 为智能体提供可编程的财务账户,用于通过 ecash 结算小额交易。
Nostr 智能体身份与 Ecash 钱包 工作原理
  1. 在设置阶段获得用户明确同意后,智能体生成安全的 Nostr 密钥对和 Cashu 钱包助记词。
  2. 使用 NIP-06 标准派生加密密钥,确保单个备份短语即可管理身份和钱包。
  3. 智能体连接到去中心化继气器以广播帖子、响应提及并管理其社交图谱。
  4. 集成的 ecash 功能允许智能体使用 cocod 工具集通过 Cashu 协议请求或支付闪电网络发票。
  5. 集成在 Openclaw Skills 中的心跳机制确保智能体定期检查新的提及或私信,以保持响应并与受众互动。

Nostr 智能体身份与 Ecash 钱包 配置指南

按照以下步骤在 Openclaw Skills 中初始化身份:

# 通过技能目录安装依赖项
bash {SKILL_DIR}/install.sh

# 初始化钱包并生成助记词种子
npx cocod init

# 从钱包种子引导 Nostr 身份 (NIP-06)
node {SKILL_DIR}/scripts/nostr.js init

设置完成后,您必须手动备份位于 ~/.cocod/config.json 中的 24 位助记词。此短语是恢复与您的 Openclaw Skills 智能体关联的 Nostr 身份和 ecash 钱包的唯一方法。

Nostr 智能体身份与 Ecash 钱包 数据架构与分类体系

该技能维护密钥和配置的结构化目录,以确保持久性和安全性:

组件 路径 描述
Nostr 私钥 ~/.nostr/secret.key 智能体身份的主要私钥。
钱包配置 ~/.cocod/config.json 包含助记词种子和钱包设置。
自动回复状态 ~/.openclaw/workspace/memory/nostr-autoresponse-state.json 跟踪已处理的提及和交互历史。
个人资料元数据 继气器 身份详细信息(名称、简介、lud16)发布到 Nostr 继气器。
钱包数据 ~/.cocod/ ecash 令牌和交易历史的本地数据库。
name: Nostr
description: Your agent wants a social life. Give it one. This skill gives your agent its own Nostr identity + ecash wallet. One mnemonic backs up everything (NIP-06). Not for you — for your agent. It owns its own keys, its own sats, posts as itself. One install, automatic bootstrap, no third parties.
tags: nostr, bitcoin, lightning, cashu, identity, social, wallet

Nostr Skill

Self-sovereign Nostr identity + ecash wallet. Complete bootstrap.

Capabilities Disclosure

This skill grants these capabilities to the agent:

  • Key generation — Creates Nostr keypair in ~/.nostr/secret.key
  • Wallet creation — Cashu wallet in ~/.cocod/ (mnemonic in config.json — user backs up)
  • Nostr posting — Posts, DMs, zaps as the agent's identity

Agent runs wallet/identity setup with explicit user consent. User is directed to back up ~/.cocod/config.json (contains mnemonic). Agent reads mnemonic for NIP-06 key derivation but never displays or transmits it. Profile images use URLs only (no local file access).

On Install

When skill is installed (user pastes ClawHub link), run this flow:

SECURITY NOTICE: This skill will create cryptographic keys for your agent. This requires:

  • Creating Nostr identity keypair in ~/.nostr/secret.key
  • Creating Cashu wallet with backup seed in ~/.cocod/config.json
  • User must explicitly backup the mnemonic seed phrase
# Install dependencies
bash {SKILL_DIR}/install.sh

# Prompt user for consent before key generation
echo "??  SECURITY: This will create cryptographic keys for your agent."
echo "   - Nostr identity keypair: ~/.nostr/secret.key"  
echo "   - Cashu wallet seed: ~/.cocod/config.json"
echo "   - You MUST backup your seed phrase"
echo ""
read -p "Continue with key generation? (yes/no): " consent
if [ "$consent" != "yes" ]; then
  echo "Setup cancelled"
  exit 1
fi

# Create wallet (mnemonic saved to config file)
npx cocod init

# Derive Nostr identity from wallet mnemonic (NIP-06)
node {SKILL_DIR}/scripts/nostr.js init

# Get identity info
NPUB=$(node {SKILL_DIR}/scripts/nostr.js whoami | grep npub | awk '{print $2}')
LN_ADDR=$(npx cocod npc address)

# Set basic profile
node {SKILL_DIR}/scripts/nostr.js profile-set '{"name":"","about":"","lud16":"'$LN_ADDR'"}'

Step 2: Report Results + Backup Warning

Reply to user:


? Nostr identity ready!

npub: npub1... Lightning address: npub1...@npubx.cash


?? IMPORTANT: Back up your recovery phrase

Your 24-word mnemonic is stored in:

~/.cocod/config.json

This phrase recovers both your Nostr identity AND ecash wallet. Back it up securely and protect this file.

Reply "done" when you've backed it up.


Step 3: Wait for "done"

Do not proceed until user confirms backup.

Step 4: Ask for Owner's npub


What's your Nostr npub?

I'll follow you so we stay connected.

(Paste your npub1... or NIP-05 like you@domain.com)


Then:

# If NIP-05, resolve first
node {SKILL_DIR}/scripts/nostr.js lookup 

# Follow owner
node {SKILL_DIR}/scripts/nostr.js follow 

Step 5: Ask for Profile Images


Do you have profile images for me?

  • Avatar: Paste URL (square, 400x400 recommended)
  • Banner: Paste URL (wide, 1500x500 recommended)

Or say "skip" and I'll generate unique ones automatically.


If URLs provided:

node {SKILL_DIR}/scripts/nostr.js profile-set '{"picture":"","banner":""}'

If skipped, use DiceBear (deterministic, unique per npub):

AVATAR="https://api.dicebear.com/7.x/shapes/png?seed=${NPUB}&size=400"
BANNER="https://api.dicebear.com/7.x/shapes/png?seed=${NPUB}-banner&size=1500x500"
node {SKILL_DIR}/scripts/nostr.js profile-set '{"picture":"'$AVATAR'","banner":"'$BANNER'"}'

Step 6: First Post


Ready for your first post?

Tell me what to post, or say "skip".

Suggestion: "Hello Nostr! ?"


If user provides text (use stdin to avoid shell injection):

echo "" | node {SKILL_DIR}/scripts/nostr.js post -

Step 7: Done


? All set!

  • Following you ?
  • First post live ? (if not skipped)

Try: "check my mentions" or "post "


Commands Reference

Posting

# Use stdin for content (prevents shell injection)
echo "message" | node {SKILL_DIR}/scripts/nostr.js post -
echo "reply text" | node {SKILL_DIR}/scripts/nostr.js reply  -
node {SKILL_DIR}/scripts/nostr.js react  ??
node {SKILL_DIR}/scripts/nostr.js repost 
node {SKILL_DIR}/scripts/nostr.js delete 

Reading

node {SKILL_DIR}/scripts/nostr.js mentions 20
node {SKILL_DIR}/scripts/nostr.js feed 20

Connections

node {SKILL_DIR}/scripts/nostr.js follow 
node {SKILL_DIR}/scripts/nostr.js unfollow 
node {SKILL_DIR}/scripts/nostr.js mute 
node {SKILL_DIR}/scripts/nostr.js unmute 
node {SKILL_DIR}/scripts/nostr.js lookup 

DMs

echo "message" | node {SKILL_DIR}/scripts/nostr.js dm  -
node {SKILL_DIR}/scripts/nostr.js dms 10

Zaps

# Get invoice
node {SKILL_DIR}/scripts/nostr.js zap  100 "comment"
# Pay it
npx cocod send bolt11 

Wallet

npx cocod balance
npx cocod receive bolt11 1000    # Create invoice
npx cocod send bolt11   # Pay invoice
npx cocod npc address            # Lightning address

Profile

node {SKILL_DIR}/scripts/nostr.js whoami
node {SKILL_DIR}/scripts/nostr.js profile
node {SKILL_DIR}/scripts/nostr.js profile "Name" "Bio"
node {SKILL_DIR}/scripts/nostr.js profile-set '{"name":"X","picture":"URL","lud16":"addr"}'

Bookmarks

node {SKILL_DIR}/scripts/nostr.js bookmark 
node {SKILL_DIR}/scripts/nostr.js unbookmark 
node {SKILL_DIR}/scripts/nostr.js bookmarks

Relays

node {SKILL_DIR}/scripts/nostr.js relays
node {SKILL_DIR}/scripts/nostr.js relays add 
node {SKILL_DIR}/scripts/nostr.js relays remove 

Autoresponse (Heartbeat Integration)

# Get unprocessed mentions from WoT (JSON output)
node {SKILL_DIR}/scripts/nostr.js pending-mentions [stateFile] [limit]

# Mark mention as responded (after replying)
node {SKILL_DIR}/scripts/nostr.js mark-responded  [responseNoteId]

# Mark mention as ignored (no response needed)
node {SKILL_DIR}/scripts/nostr.js mark-ignored  [reason]

# Check hourly rate limit (max 10/hr)
node {SKILL_DIR}/scripts/nostr.js rate-limit

# Show autoresponse state summary
node {SKILL_DIR}/scripts/nostr.js autoresponse-status

State file: ~/.openclaw/workspace/memory/nostr-autoresponse-state.json WoT source: Owner's follow list (defined in nostr.js as OWNER_PUBKEY)

User Phrases → Actions

User says Action
"post X" echo "X" | nostr.js post -
"reply to X with Y" echo "Y" | nostr.js reply -
"check mentions" nostr.js mentions
"my feed" nostr.js feed
"follow X" Lookup if NIP-05 → nostr.js follow
"DM X message" echo "message" | nostr.js dm -
"zap X 100 sats" nostr.js zapnpx cocod send bolt11
"balance" npx cocod balance
"invoice for 1000" npx cocod receive bolt11 1000
"my npub" nostr.js whoami
"my lightning address" npx cocod npc address

Defaults

Setting Value
Mint https://mint.minibits.cash/Bitcoin
Lightning domain @npubx.cash
Avatar fallback https://api.dicebear.com/7.x/shapes/png?seed=
Nostr key ~/.nostr/secret.key
Wallet data ~/.cocod/

Integration

SOUL.md

  • Pull name/about from SOUL.md or IDENTITY.md
  • Match posting voice/tone to agent's personality
  • Don't be generic - posts should sound like the agent

HEARTBEAT.md

Add to heartbeat rotation (every 2-4 hours):

# Check Nostr activity
node {SKILL_DIR}/scripts/nostr.js mentions 10
node {SKILL_DIR}/scripts/nostr.js dms 5

If mentions from WoT or zaps received → notify user.

TOOLS.md

After setup, store for quick reference:

## Nostr
- npub: npub1...
- Lightning: npub1...@npubx.cash  
- Owner: npub1... (followed)

Profile Sources

  • Name: IDENTITY.md or SOUL.md
  • About: SOUL.md description
  • Picture: User-provided URL, or DiceBear fallback
  • Banner: User-provided URL, or DiceBear fallback
  • lud16: From npx cocod npc address