bsocial

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

BSocial

BSocial

Complete on-chain social protocol for BSV blockchain. Posts, likes, follows, messages, reposts, and friend requests using BitcoinSchema.org standards.
这是适用于BSV区块链的完整链上社交协议。基于BitcoinSchema.org标准实现发帖、点赞、关注、消息、转发和好友请求功能。

When to Use

适用场景

  • Create social content (posts, replies, reposts)
  • Social actions (likes, follows, friend requests)
  • Real-time messaging (channels, direct messages)
  • Query social data by address or transaction
  • 创建社交内容(帖子、回复、转发)
  • 社交操作(点赞、关注、好友请求)
  • 实时消息(频道、私信)
  • 通过地址或交易查询社交数据

Create Operations

创建类操作

All create scripts require a funded WIF (Wallet Import Format) private key.
所有创建脚本都需要一个已充值的WIF(钱包导入格式)私钥。

Post

发帖

bash
bun run skills/bsocial/scripts/create-post.ts <wif> "Post content" [options]
bash
bun run skills/bsocial/scripts/create-post.ts <wif> "Post content" [options]

Options:

Options:

--channel <name> Post to a channel

--channel <name> Post to a channel

--url <url> Associate with URL

--url <url> Associate with URL

--tags <t1,t2> Comma-separated tags

--tags <t1,t2> Comma-separated tags

--dry-run Build tx without broadcasting

--dry-run Build tx without broadcasting

undefined
undefined

Reply

回复

bash
bun run skills/bsocial/scripts/create-reply.ts <wif> <txid> "Reply content" [--tags <t1,t2>]
bash
bun run skills/bsocial/scripts/create-reply.ts <wif> <txid> "Reply content" [--tags <t1,t2>]

Like

点赞

bash
bun run skills/bsocial/scripts/create-like.ts <wif> <txid>
bash
bun run skills/bsocial/scripts/create-like.ts <wif> <txid>

Follow

关注

bash
bun run skills/bsocial/scripts/create-follow.ts <wif> <bapId>
bash
bun run skills/bsocial/scripts/create-follow.ts <wif> <bapId>

Repost

转发

bash
bun run skills/bsocial/scripts/create-repost.ts <wif> <txid> [--context <type> --value <val>]
bash
bun run skills/bsocial/scripts/create-repost.ts <wif> <txid> [--context <type> --value <val>]

Message

发送消息

bash
bun run skills/bsocial/scripts/create-message.ts <wif> "Message" [options]
bash
bun run skills/bsocial/scripts/create-message.ts <wif> "Message" [options]

Options:

Options:

--channel <name> Send to channel

--channel <name> Send to channel

--to <bapId> Direct message to user

--to <bapId> Direct message to user

undefined
undefined

Friend

添加好友

bash
bun run skills/bsocial/scripts/create-friend.ts <wif> <bapId>
bash
bun run skills/bsocial/scripts/create-friend.ts <wif> <bapId>

Read Operations

读取类操作

Query social data from the BMAP API.
从BMAP API查询社交数据。

Posts

帖子

bash
bun run skills/bsocial/scripts/read-posts.ts <address> [--limit 20] [--json]
bash
bun run skills/bsocial/scripts/read-posts.ts <address> [--limit 20] [--json]

Likes

点赞记录

bash
bun run skills/bsocial/scripts/read-likes.ts --address <addr>
bun run skills/bsocial/scripts/read-likes.ts --txid <txid>
bash
bun run skills/bsocial/scripts/read-likes.ts --address <addr>
bun run skills/bsocial/scripts/read-likes.ts --txid <txid>

Follows

关注列表

bash
bun run skills/bsocial/scripts/read-follows.ts <address> [--limit 100] [--json]
bash
bun run skills/bsocial/scripts/read-follows.ts <address> [--limit 100] [--json]

Messages

消息

bash
bun run skills/bsocial/scripts/read-messages.ts --channel <name>
bun run skills/bsocial/scripts/read-messages.ts --address <addr>
bash
bun run skills/bsocial/scripts/read-messages.ts --channel <name>
bun run skills/bsocial/scripts/read-messages.ts --address <addr>

Friends

好友列表

bash
bun run skills/bsocial/scripts/read-friends.ts <address> [--json]
bash
bun run skills/bsocial/scripts/read-friends.ts <address> [--json]

Protocol Stack

协议栈

[B Protocol] | [MAP Protocol] | [AIP Protocol]
   content       metadata         signature
  • B Protocol: Binary content storage (text, media)
  • MAP Protocol: Metadata key-value pairs (app, type, context)
  • AIP Protocol: Author signature for verification
[B Protocol] | [MAP Protocol] | [AIP Protocol]
   content       metadata         signature
  • B Protocol:二进制内容存储(文本、媒体)
  • MAP Protocol:元数据键值对(应用、类型、上下文)
  • AIP Protocol:用于验证的作者签名

Context Types

上下文类型

ContextUse Case
tx
Reply/like a transaction
channel
Post/message to named channel
bapID
Target specific identity
url
Associate with external URL
上下文使用场景
tx
回复/点赞交易
channel
向指定频道发帖/发送消息
bapID
定位特定身份
url
关联外部URL

Dependencies

依赖项

  • @bsv/sdk
    - Transaction building
  • @bopen-io/templates
    - BSocial protocol templates
  • @bsv/sdk
    - 交易构建工具
  • @bopen-io/templates
    - BSocial协议模板

API

API

Base URL:
https://bmap-api-production.up.railway.app
基础URL:
https://bmap-api-production.up.railway.app

REST Endpoints

REST端点

EndpointDescription
/social/post/bap/{bapId}
Posts by BAP ID
/social/feed/{bapId}
Feed for BAP ID
/social/post/{txid}/like
Likes for a post
/social/bap/{bapId}/like
Likes by user
/social/friend/{bapId}
Friends for BAP ID
/social/@/{bapId}/messages
Messages for user
/social/channels/{channelId}/messages
Channel messages
端点描述
/social/post/bap/{bapId}
按BAP ID查询帖子
/social/feed/{bapId}
按BAP ID查询动态流
/social/post/{txid}/like
查询某帖子的点赞
/social/bap/{bapId}/like
查询某用户的点赞记录
/social/friend/{bapId}
查询某BAP ID的好友列表
/social/@/{bapId}/messages
查询某用户的消息
/social/channels/{channelId}/messages
查询频道消息

Query API (fallback)

查询API(备选)

  • Query:
    /q/{collection}/{base64Query}
  • SSE:
    /s/{collection}/{base64Query}
  • 查询:
    /q/{collection}/{base64Query}
  • SSE:
    /s/{collection}/{base64Query}

Ingest

数据导入

  • POST
    /ingest
    with
    { rawTx: tx.toHex() }
  • 发送POST请求到
    /ingest
    ,参数为
    { rawTx: tx.toHex() }

Friend Encryption

好友加密

Friend requests use Type42 key derivation with BRC-43 invoice numbers (
2-friend-{sha256(friendBapId)}
).
typescript
import { BAP } from "bsv-bap";

const bap = new BAP({ rootPk: wif });
const identity = bap.getId(bap.listIds()[0]);

// Get encryption pubkey for friend request
const friendPubKey = identity.getEncryptionPublicKeyWithSeed(friendBapId);

// Encrypt private message for friend
const ciphertext = identity.encryptWithSeed("secret message", friendBapId);

// Decrypt message from friend
const plaintext = identity.decryptWithSeed(ciphertext, friendBapId);
A CLI is also available:
npm install -g bsv-bap
(see
create-bap-identity
skill).
好友请求使用Type42密钥派生算法,并结合BRC-43发票编号(
2-friend-{sha256(friendBapId)}
)。
typescript
import { BAP } from "bsv-bap";

const bap = new BAP({ rootPk: wif });
const identity = bap.getId(bap.listIds()[0]);

// Get encryption pubkey for friend request
const friendPubKey = identity.getEncryptionPublicKeyWithSeed(friendBapId);

// Encrypt private message for friend
const ciphertext = identity.encryptWithSeed("secret message", friendBapId);

// Decrypt message from friend
const plaintext = identity.decryptWithSeed(ciphertext, friendBapId);
同时提供CLI工具:
npm install -g bsv-bap
(详见**
create-bap-identity
** Skill)。

See Also

另请参阅

  • references/schemas.md
    - 完整的Schema参考文档
  • BitcoinSchema.org - 协议规范