mcpField
B
Bankr Dev - Safety & Access Control

Bankr Dev - Safety & Access Control

github.com/bankrbot安全88321 次安装31 周前更新
代码仓库

关于 Bankr Dev - Safety & Access Control

Bankr Dev - Safety & Access Control 是面向 Bankr API 集成开发者的技能,介绍 API 密钥权限、网络限制、密钥管理、速率限制和交易安全措施。

主要功能

  1. 01配置 API 密钥能力
  2. 02按 IP 限制访问
  3. 03分离 Agent 与 LLM 密钥
  4. 04处理速率限制和错误
  5. 05落实交易安全检查

适用场景

  1. 01将 Agent 限定为只读工具
  2. 02限制仅服务器 IP 发起请求
  3. 03配置专用 Agent 钱包
  4. 04保护交易提交流程

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/bankrbot/claude-plugins --skill bankr-dev---safety-&-access-control

安装后在 Claude Code 中输入/bankr-dev---safety-&-access-control确认已加载。

详细介绍

安全与访问控制

Bankr API 集成的安全模式和最佳实践。

API 密钥功能标志

每个 API 密钥都有独立的开关,可在 bankr.bot/api 中管理:

标志控制内容默认值
agentApiEnabled/agent/* 端点false
llmGatewayEnabledllm.bankr.bot 上的 LLM Gatewayfalse
readOnly将 Agent 限制为只读工具false
分离 Agent 和 LLM 密钥
配置Agent API 密钥LLM Gateway 密钥
环境变量BANKR_API_KEYBANKR_LLM_KEY(未设置时回退到 API 密钥)
CLI 配置apiKeyllmKey(未设置时回退到 apiKey)

只读密钥

当 readOnly: true 时:

  • /agent/prompt 可以使用,但仅提供读取工具
  • /agent/sign 返回 403
  • /agent/submit 返回 403
// Handle read-only 403 errors
const response = await fetch(`${API_URL}/agent/sign`, { ... });
if (response.status === 403) {
  const error = await response.json();
  // error.message: "This API key has read-only access..."
}

IP 白名单

// Requests from non-whitelisted IPs get 403
// Configure allowedIps at bankr.bot/api
const response = await fetch(`${API_URL}/agent/prompt`, { ... });
if (response.status === 403) {
  const error = await response.json();
  // error.message: "IP address not allowed for this API key"
}

专用 Agent 钱包

对于自主 Agent,请创建单独的 Bankr 账户:

  1. 使用不同的电子邮箱在 bankr.bot/api 注册
  2. 生成启用了 Agent API 的 API 密钥
  3. 配置访问控制(readOnly、allowedIps)
  4. 充值少量资金
访问控制组合
用例readOnlyallowedIps资金
监控机器人是是(服务器 IP)无
交易机器人(服务器)否是(服务器 IP)有限
开发/测试否否少量
研究 Agent是否无

速率限制

层级每日限额
标准每天 100 条消息
Bankr Club每天 1,000 条消息
自定义为每个 API 密钥单独设置
// Handle 429 rate limit responses
const response = await fetch(`${API_URL}/agent/prompt`, { ... });
if (response.status === 429) {
  const error = await response.json();
  // error.resetAt: Unix timestamp when counter resets
  // error.limit: Daily limit
  // error.used: Messages used
  const retryAfter = error.resetAt - Date.now();
}

密钥管理模式

// Always use environment variables
const API_KEY = process.env.BANKR_API_KEY;
const LLM_KEY = process.env.BANKR_LLM_KEY || API_KEY;

if (!API_KEY) {
  throw new Error("BANKR_API_KEY not set. Get one at https://bankr.bot/api");
}

存储规则:

  • 服务端 Agent 和 CI/CD 使用环境变量
  • 本地开发使用 ~/.bankr/config.json(由 CLI 管理)
  • 切勿将密钥提交到源代码管理系统
  • 将 ~/.bankr/、.env 添加到 .gitignore
  • 定期轮换;若密钥遭到泄露,立即撤销

交易安全

  • /agent/submit 会立即执行,不会提示确认
  • 对于重要交易,始终使用 waitForConfirmation: true
  • 先在 Base/Polygon 上用少量资金测试
  • 验证任意交易的 calldata 来源

相关技能

  • bankr-client-patterns - 配置客户端并处理错误
  • bankr-api-basics - API 基础知识
  • bankr-sign-submit-api - 需要格外谨慎的同步端点

评论

支持 Markdown