name: erc8004-identity version: 1.0.0 description: 在BNB链上维护您的智能体链上身份(ERC-8004)。使用BNBAgent SDK安全地注册、检查状态和管理您的智能体元数据。
ERC-8004 智能体身份
此技能使您的智能体能够使用ERC-8004标准在BNB链上注册和管理自己的链上身份。
功能
- 自主注册: 将您自己注册为智能体(ERC-8004)。
- 免Gas费: 使用MegaFuel Paymaster(仅限BSC测试网)实现零成本注册。
- 身份管理: 更新您的元数据(URI)、端点和描述。
- 验证: 用户可以在8004scan.io上验证您的智能体状态。
安装
此技能需要 bnbagent Python SDK。
# 安装 bnbagent SDK(根据发布说明,从 test.pypi.org 安装)
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
bnbagent==0.1.6
# 或使用 uv(推荐,速度更快)
uv pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
bnbagent==0.1.6
安全须知
此技能专门管理用于您智能体身份的钱包。
- 密码: 钱包已加密。请设置
WALLET_PASSWORD环境变量或在提示时提供密码。 - 私钥: 本地存储在
.bnbagent_state文件中(已加密)。请勿共享此文件。
使用方法
创建一个脚本来管理您的身份(或让我为您创建一个)。
1. 注册(首次)
如果您尚未在链上注册:
import os
from bnbagent import ERC8004Agent, EVMWalletProvider, AgentEndpoint
# 1. 设置钱包和SDK
password = os.getenv("WALLET_PASSWORD", "default-secure-password")
wallet = EVMWalletProvider(password=password)
sdk = ERC8004Agent(wallet_provider=wallet, network="bsc-testnet")
# 2. 定义您的身份
agent_uri = sdk.generate_agent_uri(
name="我的智能体名称",
description="我是一个运行在OpenClaw上的自主智能体。",
endpoints=[
AgentEndpoint(
name="activity",
endpoint="https://moltbook.com/u/MyAgentName", # 示例:链接到您的社交资料
version="1.0.0"
)
]
)
# 3. 在BNB链上注册(通过Paymaster实现免Gas费)
print("正在注册...")
result = sdk.register_agent(agent_uri=agent_uri)
print(f"成功!智能体ID: {result['agentId']}")
print(f"查看已注册的智能体: https://testnet.8004scan.io/agents?chain=97")
2. 检查状态
# 检查您是否已在本地注册
info = sdk.get_local_agent_info("我的智能体名称")
if info:
print(f"我已注册!智能体ID: {info['agent_id']}")
# 获取链上详细信息
chain_info = sdk.get_agent_info(info['agent_id'])
print(f"链上地址: {chain_info['agentAddress']}")
3. 更新身份
如果您的端点或描述发生变化:
local_info = sdk.get_local_agent_info("我的智能体名称")
if local_info:
agent_id = local_info['agent_id']
# 生成新的URI
new_uri = sdk.generate_agent_uri(
name="我的智能体名称",
description="更新后的描述。",
endpoints=[...],
agent_id=agent_id
)
# 在链上更新
sdk.set_agent_uri(agent_id=agent_id, agent_uri=new_uri)
print("身份更新成功。")