name: bsocial description: 这个技能应在用户询问“发布到BSocial”、“点赞帖子”、“关注用户”、“发送消息”、“链上社交媒体”、“BMAP”、“BSocial协议”、“创建链上帖子”、“读取BSocial帖子”或需要在BSV区块链上进行社交操作(帖子、点赞、关注、消息、转发、朋友)时使用。 allowed-tools: “Bash(bun:*)”
BSocial
基于BSV区块链的完整链上社交协议。使用BitcoinSchema.org标准支持帖子、点赞、关注、消息、转发和朋友请求。
何时使用
- 创建社交内容(帖子、回复、转发)
- 社交动作(点赞、关注、朋友请求)
- 实时消息传递(频道、直接消息)
- 通过地址或交易查询社交数据
创建操作
所有创建脚本都需要一个已注资的WIF(钱包导入格式)私钥。
发布帖子
bun run skills/bsocial/scripts/create-post.ts <wif> "帖子内容" [选项]
# 选项:
# --channel <名称> 发布到频道
# --url <网址> 关联到网址
# --tags <标签1,标签2> 逗号分隔的标签
# --dry-run 构建交易但不广播
回复
bun run skills/bsocial/scripts/create-reply.ts <wif> <交易ID> "回复内容" [--tags <标签1,标签2>]
点赞
bun run skills/bsocial/scripts/create-like.ts <wif> <交易ID>
关注
bun run skills/bsocial/scripts/create-follow.ts <wif> <BAP ID>
转发
bun run skills/bsocial/scripts/create-repost.ts <wif> <交易ID> [--context <类型> --value <值>]
消息
bun run skills/bsocial/scripts/create-message.ts <wif> "消息" [选项]
# 选项:
# --channel <名称> 发送到频道
# --to <BAP ID> 直接消息给用户
朋友
bun run skills/bsocial/scripts/create-friend.ts <wif> <BAP ID>
读取操作
从BMAP API查询社交数据。
帖子
bun run skills/bsocial/scripts/read-posts.ts <地址> [--limit 20] [--json]
点赞
bun run skills/bsocial/scripts/read-likes.ts --address <地址>
bun run skills/bsocial/scripts/read-likes.ts --txid <交易ID>
关注
bun run skills/bsocial/scripts/read-follows.ts <地址> [--limit 100] [--json]
消息
bun run skills/bsocial/scripts/read-messages.ts --channel <名称>
bun run skills/bsocial/scripts/read-messages.ts --address <地址>
朋友
bun run skills/bsocial/scripts/read-friends.ts <地址> [--json]
协议栈
[B协议] | [MAP协议] | [AIP协议]
内容存储 元数据 签名验证
- B协议:二进制内容存储(文本、媒体)
- MAP协议:元数据键值对(应用、类型、上下文)
- AIP协议:作者签名用于验证
上下文类型
| 上下文 | 使用案例 |
|---|---|
tx |
回复/点赞交易 |
channel |
发布/消息到指定频道 |
bapID |
针对特定身份 |
url |
关联到外部网址 |
依赖项
@bsv/sdk- 交易构建@bopen-io/templates- BSocial协议模板
API
基础URL:https://bmap-api-production.up.railway.app
REST端点
| 端点 | 描述 |
|---|---|
/social/post/bap/{bapId} |
按BAP ID的帖子 |
/social/feed/{bapId} |
BAP ID的feed |
/social/post/{txid}/like |
帖子的点赞 |
/social/bap/{bapId}/like |
用户的点赞 |
/social/friend/{bapId} |
BAP ID的朋友 |
/social/@/{bapId}/messages |
用户的消息 |
/social/channels/{channelId}/messages |
频道的消息 |
查询API(备用)
- 查询:
/q/{collection}/{base64Query} - SSE:
/s/{collection}/{base64Query}
注入
- POST
/ingestwith{ rawTx: tx.toHex() }
朋友加密
朋友请求使用Type42密钥派生,带有BRC-43发票号码(2-friend-{sha256(friendBapId)})。
import { BAP } from "bsv-bap";
const bap = new BAP({ rootPk: wif });
const identity = bap.getId(bap.listIds()[0]);
// 获取朋友请求的加密公钥
const friendPubKey = identity.getEncryptionPublicKeyWithSeed(friendBapId);
// 为朋友加密私有消息
const ciphertext = identity.encryptWithSeed("秘密消息", friendBapId);
// 解密来自朋友的消息
const plaintext = identity.decryptWithSeed(ciphertext, friendBapId);
也可使用CLI:npm install -g bsv-bap(见**create-bap-identity**技能)。
参见
references/schemas.md- 完整模式参考- BitcoinSchema.org - 协议规范