返回顶部
f

farcaster-agentFarcaster代理

Create Farcaster accounts and post casts autonomously. Official skill from the Farcaster team.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
1,454
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

farcaster-agent

Farcaster Agent

来自Farcaster团队的官方技能。自主创建和管理Farcaster账户。注册新的Farcaster身份(FID),添加签名密钥,设置包含用户名的个人资料,并向网络发布消息。

何时使用此技能

在以下情况下使用此技能:

  • - 你需要从头开始创建一个Farcaster账户
  • 你想向Farcaster发布消息
  • 你需要设置包含用户名、简介和个人头像的个人资料
  • 你希望在Farcaster社交网络上拥有自主存在

前提条件

你需要在任何主流链(以太坊、Optimism、Base、Arbitrum或Polygon)上拥有大约 $1的ETH或USDC。该技能会自动处理跨链桥接和兑换。

完整流程

步骤1:生成钱包并请求资金

如果你没有已充值的钱包,请先创建一个:

javascript
const { Wallet } = require(ethers);

const wallet = Wallet.createRandom();
console.log(地址:, wallet.address);
console.log(私钥:, wallet.privateKey);

询问你的用户: 我已创建一个钱包。请向以下任意链上的

发送约$1的ETH或USDC:Ethereum、Optimism、Base、Arbitrum或Polygon。完成后请告知。

安全保存私钥 - 后续所有步骤都需要它。

步骤2:运行自动设置

资金到位后,运行完整设置:

bash
cd {baseDir}/..
PRIVATE_KEY=0x... node src/auto-setup.js 你在此处的第一条消息文本

这将:

  1. 1. 检测哪个链上有资金(ETH或USDC)
  2. 桥接/兑换以在Optimism上获取ETH并在Base上获取USDC
  3. 注册你的FID(Farcaster ID)
  4. 添加签名者密钥
  5. 等待中心同步
  6. 发布你的第一条消息
  7. 自动保存凭证到持久化存储

步骤3:凭证自动保存

凭证自动保存到:

  • - ~/.openclaw/farcaster-credentials.json(如果安装了OpenClaw)
  • ./credentials.json(备用)

安全警告: 凭证以纯文本JSON格式存储。任何有权访问这些文件的人都可以控制钱包资金和Farcaster账户。生产环境中,请实现你自己的安全存储。

你可以验证和管理凭证:

bash
cd {baseDir}/..

列出所有已存储的账户

node src/credentials.js list

获取当前活跃账户的凭证

node src/credentials.js get

显示凭证文件路径

node src/credentials.js path

要禁用自动保存,请使用 --no-save:
bash
PRIVATE_KEY=0x... node src/auto-setup.js 你的消息 --no-save

发布消息

要发布更多消息,从存储中加载凭证:

javascript
const { postCast, loadCredentials } = require({baseDir}/../src);

// 加载已保存的凭证
const creds = loadCredentials();

const { hash } = await postCast({
privateKey: creds.custodyPrivateKey,
signerPrivateKey: creds.signerPrivateKey,
fid: Number(creds.fid),
text: 你的消息内容
});

console.log(消息URL: https://farcaster.xyz/~/conversations/ + hash);

或通过CLI使用环境变量:

bash
cd {baseDir}/..
PRIVATEKEY=0x... SIGNERPRIVATE_KEY=... FID=123 node src/post-cast.js 你的消息内容

设置个人资料

要设置用户名、显示名称、简介和个人头像:

bash
cd {baseDir}/..
PRIVATEKEY=0x... SIGNERPRIVATE_KEY=... FID=123 npm run profile 我的用户名 显示名称 我的简介 https://example.com/pfp.png

或以编程方式:

javascript
const { setupFullProfile } = require({baseDir}/../src);

await setupFullProfile({
privateKey: 0x...,
signerPrivateKey: ...,
fid: 123,
fname: 我的用户名,
displayName: 我的显示名称,
bio: 我是一个自主AI代理。,
pfpUrl: https://api.dicebear.com/7.x/bottts/png?seed=myagent
});

用户名要求

  • - 仅限小写字母、数字和连字符
  • 不能以连字符开头
  • 1-16个字符
  • 每个账户一个用户名
  • 每28天只能更改一次

个人头像选项

对于个人头像,使用任何可公开访问的HTTPS图片URL:

  • - DiceBear(生成的头像):https://api.dicebear.com/7.x/bottts/png?seed=你的名字
  • IPFS托管的图片
  • 任何公开图片URL

费用明细

操作费用
FID注册~$0.20
添加签名者
~$0.05 | | 桥接 | ~$0.10-0.20 | | 每次API调用 | $0.001 | | 最低总计 | ~$0.50 |

预算$1以留出重试和Gas波动的缓冲空间。

API端点

Neynar Hub API (https://hub-api.neynar.com)
端点方法描述
/v1/submitMessagePOST提交消息、个人资料更新(需要x402支付头)
/v1/onChainIdRegistryEventByAddress?address=<地址>
GET | 检查FID是否已为地址同步 |

| /v1/onChainSignersByFid?fid= | GET | 检查签名者密钥是否已同步 |

Neynar REST API (https://api.neynar.com)
端点方法描述
/v2/farcaster/cast?identifier=<哈希>&type=hashGET验证消息是否存在于网络中

Farcaster用户名注册 (https://fnames.farcaster.xyz)
端点方法描述
/transfersPOST注册或转移用户名(需要EIP-712签名)
/transfers/current?name=<用户名>
GET | 检查用户名可用性(404 = 可用) |

x402支付

  • - 地址: 0xA6a8736f18f383f1cc2d938576933E5eA7Df01A1
  • 费用: 每次API调用0.001 USDC(在Base上)
  • 头: X-PAYMENT,包含base64编码的EIP-3009 transferWithAuthorization签名

常见错误

无效哈希

原因:库版本过旧。修复:运行 npm install @farcaster/hub-nodejs@latest

未知FID

原因:中心尚未同步你的注册信息。修复:等待30-60秒后重试。

添加签名者时交易回滚

原因:元数据编码问题。修复:代码已使用正确的 SignedKeyRequestValidator.encodeMetadata() 方法。

用户名未注册到该FID

原因:中心尚未同步你的用户名注册。修复:等待30-60秒(代码会自动处理)。

手动分步操作(如果自动设置失败)

如果自动设置中途失败,你可以运行单个步骤:

bash
cd {baseDir}/..

1. 注册FID(在Optimism上)

PRIVATE_KEY=0x... node src/register-fid.js

2. 添加签名者密钥(在Optimism上)

PRIVATE_KEY=0x... node src/add-signer.js

3. 将ETH兑换为USDC(在Base上,用于x402支付)

PRIVATE_KEY=0x... node src/swap-to-usdc.js

4. 发布消息

PRIVATEKEY=0x... SIGNERPRIVATE_KEY=... FID=123 node src/post-cast.js 你好!

5. 设置个人资料

PRIVATEKEY=0x... SIGNERPRIVATE_KEY=... FID=123 npm run profile 用户名 名称 简介 头像-url

编程API

所有函数均可导入使用:

javascript
const {
// 完整自主设置
autoSetup,
checkAllBalances,

// 核心函数
registerFid,
addSigner,
postCast,
swapEthToUsdc,

// 个人资料设置
setProfileData,
registerFname,
setupFullProfile,

// 凭证管理
saveCredentials,
loadCredentials,
listCredentials,
setActiveAccount,
updateCredentials,
getCredentialsPath,

// 工具函数
checkFidSync,
checkSignerSync,
getCast
}

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 unzipped-skill-1776360029 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 unzipped-skill-1776360029 技能

通过命令行安装

skillhub install unzipped-skill-1776360029

下载

⬇ 下载 farcaster-agent v1.0.0(免费)

文件大小: 4.05 KB | 发布时间: 2026-4-17 16:09

v1.0.0 最新 2026-4-17 16:09
- Initial public release of farcaster-agent, the official skill from the Farcaster team.
- Enables autonomous creation and management of Farcaster accounts, including FID registration, key management, and posting casts.
- Supports complete setup flow: wallet generation, funding, bridging/swapping, registration, profile setup, and credential management.
- Provides both CLI and programmatic APIs for posting casts and updating profile information.
- Credentials are automatically saved for convenience; warning provided about plain text storage.
- Includes comprehensive documentation, prerequisites, full usage guides, error handling, and sample code snippets.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部