diff --git a/README.md b/README.md index 816a11f3..d6a1ad90 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,12 @@ Skills are drop-in modules. No additional configuration required for basic usage | [bankr](https://bankr.bot) | [bankr](bankr/) | Financial infrastructure for autonomous agents. Token launches, payment processing, trading, yield automation. Agents earn and spend independently. | | [8004.org](https://8004.org) | [erc-8004](erc-8004/) | Ethereum agent registry using ERC-8004 standard. Mint agent NFTs, establish onchain identity, build reputation. | | botchan | [botchan](botchan/) | Onchain messaging protocol on Base. Agent feeds, DMs, permanent data storage. | +| [Clanker](https://clanker.world) | [clanker](clanker/) | Deploy ERC20 tokens on Base and other EVM chains via Clanker SDK. | +| [Coinbase](https://onchainkit.xyz) | [onchainkit](onchainkit/) | Build onchain apps with React components from Coinbase's OnchainKit. | +| [Endaoment](https://endaoment.org) | [endaoment](endaoment/) | Donate to charities onchain via Endaoment. Supports Base, Ethereum, Optimism. | +| [ENS](https://ens.domains) | [ens-primary-name](ens-primary-name/) | Set your primary ENS name on Base and other L2s. | | [qrcoin](https://qrcoin.fun) | [qrcoin](qrcoin/) | QR code auction platform on Base. Programmatic bidding for URL display. | +| [Veil Cash](https://veil.cash) | [veil](veil/) | Privacy and shielded transactions on Base via ZK proofs. | | yoink | [yoink](yoink/) | Onchain capture-the-flag on Base. | | base | — | Planned | | neynar | — | Planned | @@ -44,14 +49,18 @@ openclaw-skills/ │ └── scripts/ │ └── bankr.sh │ -├── base/ # Base (placeholder) -│ └── SKILL.md -├── neynar/ # Neynar (placeholder) -│ └── SKILL.md -├── qrcoin/ # QR Coin (community) -│ └── SKILL.md -└── zapper/ # Zapper (placeholder) - └── SKILL.md +├── botchan/ # Onchain agent messaging +├── clanker/ # ERC20 token deployment +├── endaoment/ # Charity donations +├── ens-primary-name/ # ENS reverse resolution +├── erc-8004/ # Agent registration +├── onchainkit/ # Coinbase OnchainKit +├── veil/ # Privacy/shielded txns +├── qrcoin/ # QR code auctions +├── yoink/ # Capture-the-flag game +├── base/ # (placeholder) +├── neynar/ # (placeholder) +└── zapper/ # (placeholder) ``` ## Install Instructions diff --git a/bankr/SKILL.md b/bankr/SKILL.md index a5ee4bee..73332874 100644 --- a/bankr/SKILL.md +++ b/bankr/SKILL.md @@ -1,68 +1,218 @@ --- name: bankr -description: AI-powered crypto trading agent via natural language. Use when the user wants to trade crypto (buy/sell/swap tokens), check portfolio balances, view token prices, transfer crypto, manage NFTs, use leverage, bet on Polymarket, deploy tokens, set up automated trading strategies, submit raw transactions, execute calldata, or send transaction JSON. Supports Base, Ethereum, Polygon, Solana, and Unichain. Comprehensive capabilities include trading, portfolio management, market research, NFT operations, prediction markets, leverage trading, DeFi operations, automation, and arbitrary transaction submission. +description: AI-powered crypto trading agent and LLM gateway via natural language. Use when the user wants to trade crypto, check portfolio balances, view token prices, transfer crypto, manage NFTs, use leverage, bet on Polymarket, deploy tokens, set up automated trading, sign and submit raw transactions, or access LLM models through the Bankr LLM gateway funded by your Bankr wallet. Supports Base, Ethereum, Polygon, Solana, and Unichain. metadata: { "clawdbot": { "emoji": "📺", "homepage": "https://bankr.bot", - "requires": { "bins": ["curl", "jq"] }, + "requires": { "bins": ["bankr"] }, }, } --- # Bankr -Execute crypto trading and DeFi operations using natural language through Bankr's AI agent API. +Execute crypto trading and DeFi operations using natural language. Two integration options: -## Quick Start +1. **Bankr CLI** (recommended) — Install `@bankr/cli` for a batteries-included terminal experience +2. **REST API** — Call `https://api.bankr.bot` directly from any language or tool -### First-Time Setup +Both use the same API key and the same async job workflow under the hood. + +## Getting an API Key + +Before using either option, you need a Bankr API key: + +1. Visit [bankr.bot/api](https://bankr.bot/api) +2. **Sign up / Sign in** — Enter your email and the one-time passcode (OTP) sent to it +3. **Generate an API key** — Create a key with **Agent API** access enabled (the key starts with `bk_...`) -There are two ways to get started: +Creating a new account automatically provisions **EVM wallets** (Base, Ethereum, Polygon, Unichain) and a **Solana wallet** — no manual wallet setup needed. -#### Option A: User provides an existing API key +## Option 1: Bankr CLI (Recommended) -If the user already has a Bankr API key, they can provide it directly: +### Install ```bash -mkdir -p ~/.clawdbot/skills/bankr -cat > ~/.clawdbot/skills/bankr/config.json << 'EOF' -{ - "apiKey": "bk_YOUR_KEY_HERE", - "apiUrl": "https://api.bankr.bot" -} -EOF +bun install -g @bankr/cli ``` -API keys can be created and managed at [bankr.bot/api](https://bankr.bot/api). The key must have **Agent API** access enabled. +Or with npm: + +```bash +npm install -g @bankr/cli +``` + +### First-Time Setup + +```bash +# Authenticate with Bankr (interactive — opens browser or paste key) +bankr login + +# Verify your identity +bankr whoami +``` -#### Option B: Create a new account (guided by Clawd) +The `bankr login` command gives you two choices: -Clawd can walk the user through the full signup flow: +**A) Open the Bankr dashboard** — The CLI opens [bankr.bot/api](https://bankr.bot/api) where you generate a key and paste it back. -1. **Sign up / Sign in** — User provides their email address. Bankr sends a one-time passcode (OTP) to that email. Creating a new account automatically provisions **EVM wallets** (Base, Ethereum, Polygon, Unichain) and a **Solana wallet** — no manual wallet setup needed. -2. **Enter OTP** — User checks their email and provides the OTP code. -3. **Generate API key** — Once authenticated, navigate to [bankr.bot/api](https://bankr.bot/api) to create an API key with **Agent API** access enabled. -4. **Configure** — Save the key (starts with `bk_`) to config: +**B) Paste an existing API key** — Select "Paste an existing Bankr API key" and enter it directly. + +#### Separate LLM Gateway Key (Optional) + +If your LLM gateway key differs from your API key, pass `--llm-key` during login or run `bankr config set llmKey YOUR_LLM_KEY` afterward. When not set, the API key is used for both. See [references/llm-gateway.md](references/llm-gateway.md) for full details. + +#### Non-Interactive Login (for AI agents) + +If you cannot interact with terminal prompts, use these flags: + +**If the user needs to create an API key:** +1. Run `bankr login --url` — prints the dashboard URL +2. Present the URL to the user, ask them to generate a `bk_...` key +3. Run `bankr login --api-key bk_THE_KEY` + +**If the user already has an API key:** ```bash -mkdir -p ~/.clawdbot/skills/bankr -cat > ~/.clawdbot/skills/bankr/config.json << 'EOF' -{ - "apiKey": "bk_YOUR_KEY_HERE", - "apiUrl": "https://api.bankr.bot" -} -EOF +bankr login --api-key bk_YOUR_KEY_HERE ``` #### Verify Setup ```bash -scripts/bankr.sh "What is my balance?" +bankr whoami +bankr prompt "What is my balance?" +``` + +## Option 2: REST API (Direct) + +No CLI installation required — call the API directly with `curl`, `fetch`, or any HTTP client. + +### Authentication + +All requests require an `X-API-Key` header: + +```bash +curl -X POST "https://api.bankr.bot/agent/prompt" \ + -H "X-API-Key: bk_YOUR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"prompt": "What is my ETH balance?"}' +``` + +### Quick Example: Submit → Poll → Complete + +```bash +# 1. Submit a prompt — returns a job ID +JOB=$(curl -s -X POST "https://api.bankr.bot/agent/prompt" \ + -H "X-API-Key: $BANKR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"prompt": "What is my ETH balance?"}') +JOB_ID=$(echo "$JOB" | jq -r '.jobId') + +# 2. Poll until terminal status +while true; do + RESULT=$(curl -s "https://api.bankr.bot/agent/job/$JOB_ID" \ + -H "X-API-Key: $BANKR_API_KEY") + STATUS=$(echo "$RESULT" | jq -r '.status') + [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ] || [ "$STATUS" = "cancelled" ] && break + sleep 2 +done + +# 3. Read the response +echo "$RESULT" | jq -r '.response' ``` +### Conversation Threads + +Every prompt response includes a `threadId`. Pass it back to continue the conversation: + +```bash +# Start — the response includes a threadId +curl -X POST "https://api.bankr.bot/agent/prompt" \ + -H "X-API-Key: $BANKR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"prompt": "What is the price of ETH?"}' +# → {"jobId": "job_abc", "threadId": "thr_XYZ", ...} + +# Continue — pass threadId to maintain context +curl -X POST "https://api.bankr.bot/agent/prompt" \ + -H "X-API-Key: $BANKR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"prompt": "And what about SOL?", "threadId": "thr_XYZ"}' +``` + +Omit `threadId` to start a new conversation. CLI equivalent: `bankr prompt --continue` (reuses last thread) or `bankr prompt --thread `. + +### API Endpoints Summary + +| Endpoint | Method | Description | +|----------|--------|-------------| +| `/agent/prompt` | POST | Submit a prompt (async, returns job ID) | +| `/agent/job/{jobId}` | GET | Check job status and results | +| `/agent/job/{jobId}/cancel` | POST | Cancel a running job | +| `/agent/sign` | POST | Sign messages/transactions (sync) | +| `/agent/submit` | POST | Submit raw transactions (sync) | + +For full API details (request/response schemas, job states, rich data, polling strategy), see: + +**Reference**: [references/api-workflow.md](references/api-workflow.md) | [references/sign-submit-api.md](references/sign-submit-api.md) + +## CLI Command Reference + +### Core Commands + +| Command | Description | +|---------|-------------| +| `bankr login` | Authenticate with the Bankr API (interactive) | +| `bankr login --url` | Print dashboard URL for API key generation | +| `bankr login --api-key ` | Login with an API key directly (non-interactive) | +| `bankr login --api-key --llm-key ` | Login with separate LLM gateway key | +| `bankr logout` | Clear stored credentials | +| `bankr whoami` | Show current authentication info | +| `bankr prompt ` | Send a prompt to the Bankr AI agent | +| `bankr prompt --continue ` | Continue the most recent conversation thread | +| `bankr prompt --thread ` | Continue a specific conversation thread | +| `bankr status ` | Check the status of a running job | +| `bankr cancel ` | Cancel a running job | +| `bankr skills` | Show all Bankr AI agent skills with examples | + +### Configuration Commands + +| Command | Description | +|---------|-------------| +| `bankr config get [key]` | Get config value(s) | +| `bankr config set ` | Set a config value | +| `bankr --config ` | Use a custom config file path | + +Valid config keys: `apiKey`, `apiUrl`, `llmKey`, `llmUrl` + +Default config location: `~/.bankr/config.json`. Override with `--config` or `BANKR_CONFIG` env var. + +### Environment Variables + +| Variable | Description | +|----------|-------------| +| `BANKR_API_KEY` | API key (overrides stored key) | +| `BANKR_API_URL` | API URL (default: `https://api.bankr.bot`) | +| `BANKR_LLM_KEY` | LLM gateway key (falls back to `BANKR_API_KEY` if not set) | +| `BANKR_LLM_URL` | LLM gateway URL (default: `https://llm.bankr.bot`) | + +Environment variables override config file values. Config file values override defaults. + +### LLM Gateway Commands + +| Command | Description | +|---------|-------------| +| `bankr llm models` | List available LLM models | +| `bankr llm setup openclaw [--install]` | Generate or install OpenClaw config | +| `bankr llm setup opencode [--install]` | Generate or install OpenCode config | +| `bankr llm setup claude` | Show Claude Code environment setup | +| `bankr llm setup cursor` | Show Cursor IDE setup instructions | +| `bankr llm claude [args...]` | Launch Claude Code via the Bankr LLM Gateway | + ## Core Usage ### Simple Query @@ -70,11 +220,47 @@ scripts/bankr.sh "What is my balance?" For straightforward requests that complete quickly: ```bash -scripts/bankr.sh "What is my ETH balance?" -scripts/bankr.sh "What's the price of Bitcoin?" +bankr prompt "What is my ETH balance?" +bankr prompt "What's the price of Bitcoin?" ``` -The main script handles the full submit-poll-complete workflow automatically. +The CLI handles the full submit-poll-complete workflow automatically. You can also use the shorthand — any unrecognized command is treated as a prompt: + +```bash +bankr What is the price of ETH? +``` + +### Interactive Prompt + +For prompts containing `$` or special characters that the shell would expand: + +```bash +# Interactive mode — no shell expansion issues +bankr prompt +# Then type: Buy $50 of ETH on Base + +# Or pipe input +echo 'Buy $50 of ETH on Base' | bankr prompt +``` + +### Conversation Threads + +Continue a multi-turn conversation with the agent: + +```bash +# First prompt — starts a new thread automatically +bankr prompt "What is the price of ETH?" +# → Thread: thr_ABC123 + +# Continue the conversation (agent remembers the ETH context) +bankr prompt --continue "And what about BTC?" +bankr prompt -c "Compare them" + +# Resume any thread by ID +bankr prompt --thread thr_ABC123 "Show me ETH chart" +``` + +Thread IDs are automatically saved to config after each prompt. The `--continue` / `-c` flag reuses the last thread. ### Manual Job Control @@ -82,15 +268,53 @@ For advanced use or long-running operations: ```bash # Submit and get job ID -JOB_ID=$(scripts/bankr-submit.sh "Buy $100 of ETH" | jq -r '.jobId') +bankr prompt "Buy $100 of ETH" +# → Job submitted: job_abc123 -# Poll for status -scripts/bankr-status.sh "$JOB_ID" +# Check status of a specific job +bankr status job_abc123 # Cancel if needed -scripts/bankr-cancel.sh "$JOB_ID" +bankr cancel job_abc123 +``` + +## LLM Gateway + +The [Bankr LLM Gateway](https://docs.bankr.bot/llm-gateway/overview) is a unified API for Claude, Gemini, GPT, and other models — multi-provider access, cost tracking, automatic failover, and SDK compatibility through a single endpoint. + +**Base URL:** `https://llm.bankr.bot` + +Uses your `llmKey` if configured, otherwise falls back to your API key. + +### Quick Commands + +```bash +bankr llm models # List available models +bankr llm credits # Check credit balance +bankr llm setup openclaw --install # Install Bankr provider into OpenClaw +bankr llm setup opencode --install # Install Bankr provider into OpenCode +bankr llm setup claude # Print Claude Code env vars +bankr llm setup cursor # Cursor setup instructions +bankr llm claude # Launch Claude Code through gateway +bankr llm claude --model claude-opus-4.6 # Launch with specific model +``` + +### Direct SDK Usage + +The gateway works with standard OpenAI and Anthropic SDKs — just override the base URL: + +```bash +# OpenAI-compatible +curl -X POST "https://llm.bankr.bot/v1/chat/completions" \ + -H "Authorization: Bearer $BANKR_LLM_KEY" \ + -H "Content-Type: application/json" \ + -d '{"model": "claude-sonnet-4.5", "messages": [{"role": "user", "content": "Hello"}]}' ``` +For full model list, provider config JSON shape, SDK examples (Python, TypeScript), all setup commands, and troubleshooting, see: + +**Reference**: [references/llm-gateway.md](references/llm-gateway.md) + ## Capabilities Overview ### Trading Operations @@ -212,63 +436,66 @@ scripts/bankr-cancel.sh "$JOB_ID" ```bash # Check balance -scripts/bankr.sh "What is my ETH balance on Base?" +bankr prompt "What is my ETH balance on Base?" # Check price -scripts/bankr.sh "What's the current price of PEPE?" +bankr prompt "What's the current price of PEPE?" # Then trade -scripts/bankr.sh "Buy $20 of PEPE on Base" +bankr prompt "Buy $20 of PEPE on Base" ``` ### Portfolio Review ```bash # Full portfolio -scripts/bankr.sh "Show my complete portfolio" +bankr prompt "Show my complete portfolio" # Chain-specific -scripts/bankr.sh "What tokens do I have on Base?" +bankr prompt "What tokens do I have on Base?" # Token-specific -scripts/bankr.sh "Show my ETH across all chains" +bankr prompt "Show my ETH across all chains" ``` ### Set Up Automation ```bash # DCA strategy -scripts/bankr.sh "DCA $100 into ETH every week" +bankr prompt "DCA $100 into ETH every week" # Stop loss protection -scripts/bankr.sh "Set stop loss for my ETH at $2,500" +bankr prompt "Set stop loss for my ETH at $2,500" # Limit order -scripts/bankr.sh "Buy ETH if price drops to $3,000" +bankr prompt "Buy ETH if price drops to $3,000" ``` ### Market Research ```bash # Price and analysis -scripts/bankr.sh "Do technical analysis on ETH" +bankr prompt "Do technical analysis on ETH" # Trending tokens -scripts/bankr.sh "What tokens are trending on Base?" +bankr prompt "What tokens are trending on Base?" # Compare tokens -scripts/bankr.sh "Compare ETH vs SOL" +bankr prompt "Compare ETH vs SOL" ``` ## API Workflow Bankr uses an asynchronous job-based API: -1. **Submit** - Send prompt, get job ID -2. **Poll** - Check status every 2 seconds -3. **Complete** - Process results when done +1. **Submit** — Send prompt (with optional `threadId`), get job ID and thread ID +2. **Poll** — Check status every 2 seconds +3. **Complete** — Process results when done +4. **Continue** — Reuse `threadId` for multi-turn conversations + +The `bankr prompt` command handles this automatically. When using the REST API directly, implement the poll loop yourself (see Option 2 above or the reference below). For manual job control via CLI, use `bankr status ` and `bankr cancel `. -The `bankr.sh` wrapper handles this automatically. For details on the API structure, job states, polling strategy, and error handling, see: +For details on the API structure, job states, polling strategy, and error handling, see: **Reference**: [references/api-workflow.md](references/api-workflow.md) @@ -290,7 +517,7 @@ These endpoints return immediately (no polling required) and are ideal for: Common issues and fixes: -- **Authentication errors** → Check API key setup +- **Authentication errors** → Run `bankr login` or check `bankr whoami` (CLI), or verify your `X-API-Key` header (REST API) - **Insufficient balance** → Add funds or reduce amount - **Token not found** → Verify symbol and chain - **Transaction reverted** → Check parameters and balances @@ -465,21 +692,43 @@ curl -X POST "https://api.bankr.bot/agent/submit" \ ## Resources -- **Agent API Reference**: https://www.notion.so/Agent-API-2e18e0f9661f80cb83ccfc046f8872e3 +- **Documentation**: https://docs.bankr.bot +- **LLM Gateway Docs**: https://docs.bankr.bot/llm-gateway/overview - **API Key Management**: https://bankr.bot/api - **Terminal**: https://bankr.bot/terminal +- **CLI Package**: https://www.npmjs.com/package/@bankr/cli - **Twitter**: @bankr_bot ## Troubleshooting -### Scripts Not Working +### CLI Not Found + +```bash +# Verify installation +which bankr + +# Reinstall if needed +bun install -g @bankr/cli +``` + +### Authentication Issues +**CLI:** ```bash -# Ensure scripts are executable -chmod +x ~/.clawdbot/skills/bankr/scripts/*.sh +# Check current auth +bankr whoami + +# Re-authenticate +bankr login -# Test connectivity -curl -I https://api.bankr.bot +# Check LLM key specifically +bankr config get llmKey +``` + +**REST API:** +```bash +# Test your API key +curl -s "https://api.bankr.bot/_health" -H "X-API-Key: $BANKR_API_KEY" ``` ### API Errors @@ -488,15 +737,15 @@ See [references/error-handling.md](references/error-handling.md) for comprehensi ### Getting Help -1. Check error message in response JSON -2. Consult relevant reference document -3. Verify configuration and connectivity -4. Test with simple queries first +1. Check error message in CLI output or API response +2. Run `bankr whoami` to verify auth (CLI) or test with a curl to `/_health` (REST API) +3. Consult relevant reference document +4. Test with simple queries first (`bankr prompt "What is my balance?"` or `POST /agent/prompt`) --- -**💡 Pro Tip**: The most common issue is not specifying the chain for tokens. When in doubt, always include "on Base" or "on Ethereum" in your prompt. +**Pro Tip**: The most common issue is not specifying the chain for tokens. When in doubt, always include "on Base" or "on Ethereum" in your prompt. -**⚠️ Security**: Keep your API key private. Never commit config.json to version control. Only trade amounts you can afford to lose. +**Security**: Keep your API key private. Never commit your config file to version control. Only trade amounts you can afford to lose. -**🚀 Quick Win**: Start by checking your portfolio to see what's possible, then try a small $5-10 trade on Base to get familiar with the flow. +**Quick Win**: Start by checking your portfolio (`bankr prompt "Show my portfolio"`) to see what's possible, then try a small $5-10 trade on Base to get familiar with the flow. diff --git a/bankr/references/api-workflow.md b/bankr/references/api-workflow.md index ff42d685..b5b1a683 100644 --- a/bankr/references/api-workflow.md +++ b/bankr/references/api-workflow.md @@ -4,9 +4,23 @@ Understanding the asynchronous job pattern for Bankr API operations. **Source**: [Agent API Reference](https://www.notion.so/Agent-API-2e18e0f9661f80cb83ccfc046f8872e3) -## Core Pattern: Submit-Poll-Complete +## Using the Bankr CLI -All Bankr operations follow this pattern: +The CLI handles submit-poll-complete automatically. For installation and login, see the main [SKILL.md](../SKILL.md). + +```bash +bankr prompt "What is my ETH balance?" # submit + poll + display +bankr status # check a specific job +bankr cancel # cancel a running job +``` + +## Using the REST API Directly + +Call the endpoints below with `curl`, `fetch`, or any HTTP client. All requests require an `X-API-Key` header. + +### Core Pattern: Submit-Poll-Complete + +All operations follow this pattern: ``` 1. SUBMIT → Send prompt, get job ID @@ -19,6 +33,8 @@ All Bankr operations follow this pattern: ### POST /agent/prompt Submit a natural language prompt to start a job. +**CLI equivalent:** `bankr prompt "What is my ETH balance?"` + **Request:** ```bash curl -X POST "https://api.bankr.bot/agent/prompt" \ @@ -27,14 +43,24 @@ curl -X POST "https://api.bankr.bot/agent/prompt" \ -d '{"prompt": "What is my ETH balance?"}' ``` +**Continue a conversation:** +```bash +curl -X POST "https://api.bankr.bot/agent/prompt" \ + -H "X-API-Key: YOUR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"prompt": "And what about SOL?", "threadId": "thr_ABC123"}' +``` + **Request Body:** - **prompt** (string, required): The prompt to send to the AI agent (max 10,000 characters) +- **threadId** (string, optional): Continue an existing conversation thread. If omitted, a new thread is created. **Response (202 Accepted):** ```json { "success": true, "jobId": "job_abc123", + "threadId": "thr_XYZ789", "status": "pending", "message": "Job submitted successfully" } @@ -51,6 +77,8 @@ curl -X POST "https://api.bankr.bot/agent/prompt" \ ### GET /agent/job/{jobId} Check job status and results. +**CLI equivalent:** `bankr status job_abc123` + **Request:** ```bash curl -X GET "https://api.bankr.bot/agent/job/job_abc123" \ @@ -62,6 +90,7 @@ curl -X GET "https://api.bankr.bot/agent/job/job_abc123" \ { "success": true, "jobId": "job_abc123", + "threadId": "thr_XYZ789", "status": "completed", "prompt": "What is my ETH balance?", "response": "You have 0.5 ETH worth approximately $1,825.", @@ -87,6 +116,8 @@ curl -X GET "https://api.bankr.bot/agent/job/job_abc123" \ ### POST /agent/job/{jobId}/cancel Cancel a pending or processing job. Cancel requests are idempotent — cancelling an already-cancelled job returns success. +**CLI equivalent:** `bankr cancel job_abc123` + **Request:** ```bash curl -X POST "https://api.bankr.bot/agent/job/job_abc123/cancel" \ @@ -129,6 +160,7 @@ curl -X POST "https://api.bankr.bot/agent/job/job_abc123/cancel" \ ### Standard Fields - **success**: Boolean, true if request succeeded - **jobId**: Unique job identifier +- **threadId**: Conversation thread ID (reuse to continue the conversation) - **status**: Current job status (`pending`, `processing`, `completed`, `failed`, `cancelled`) - **prompt**: Original user prompt - **createdAt**: ISO 8601 timestamp diff --git a/bankr/references/error-handling.md b/bankr/references/error-handling.md index 1f08336a..bc60e0cf 100644 --- a/bankr/references/error-handling.md +++ b/bankr/references/error-handling.md @@ -11,24 +11,25 @@ Resolve Bankr API errors and common issues. ### Resolution Steps -**1. Get API Key** -Visit https://bankr.bot/api to create a new API key +**1. Install the Bankr CLI** +```bash +bun install -g @bankr/cli +``` + +**2. Authenticate** +```bash +bankr login +``` -**2. Create Configuration** +Or if you already have an API key from https://bankr.bot/api: ```bash -mkdir -p ~/.clawdbot/skills/bankr -cat > ~/.clawdbot/skills/bankr/config.json << 'EOF' -{ - "apiKey": "bk_your_actual_key_here", - "apiUrl": "https://api.bankr.bot" -} -EOF +bankr config set apiKey bk_your_actual_key_here ``` **3. Verify Setup** -Test with a simple command: ```bash -~/.clawdbot/skills/bankr/scripts/bankr.sh "What is my balance?" +bankr whoami +bankr prompt "What is my balance?" ``` ### Common API Key Issues @@ -162,39 +163,41 @@ curl -sf https://api.bankr.bot || echo "Connection failed" ## Configuration Issues -### Config File Not Found +### CLI Not Installed ```bash -# Create config directory -mkdir -p ~/.clawdbot/skills/bankr - -# Create config file -cat > ~/.clawdbot/skills/bankr/config.json << 'EOF' -{ - "apiKey": "bk_your_key_here", - "apiUrl": "https://api.bankr.bot" -} -EOF -``` +# Install the Bankr CLI +bun install -g @bankr/cli -### Invalid JSON -```bash -# Validate JSON -jq . ~/.clawdbot/skills/bankr/config.json +# Or with npm +npm install -g @bankr/cli -# If error, fix formatting +# Verify installation +which bankr ``` -### Missing jq Command +### Not Authenticated ```bash -# macOS -brew install jq +# Authenticate (opens browser for email/OTP flow) +bankr login + +# Or set API key directly +bankr config set apiKey bk_your_key_here + +# Set separate LLM key (optional, falls back to API key) +bankr config set llmKey your_llm_key_here -# Linux (Debian/Ubuntu) -sudo apt install jq +# Verify +bankr whoami +``` + +Config is stored at `~/.bankr/config.json`. View current values with `bankr config get`. -# Linux (RHEL/CentOS) -sudo yum install jq +### REST API Authentication +If using the API directly without the CLI, test your key with: +```bash +curl -s "https://api.bankr.bot/_health" -H "X-API-Key: $BANKR_API_KEY" ``` +Set `BANKR_API_KEY` (and optionally `BANKR_LLM_KEY` for the LLM gateway) as environment variables. ## User-Friendly Error Messages @@ -260,11 +263,11 @@ Before reporting an issue, check: ### Check Status ```bash -# Test API connectivity -~/.clawdbot/skills/bankr/scripts/bankr.sh "ping" +# Verify authentication +bankr whoami -# Check your balance (validates auth) -~/.clawdbot/skills/bankr/scripts/bankr.sh "What is my balance?" +# Test with a simple query +bankr prompt "What is my balance?" ``` ### Gather Information diff --git a/bankr/references/llm-gateway.md b/bankr/references/llm-gateway.md new file mode 100644 index 00000000..d70669c0 --- /dev/null +++ b/bankr/references/llm-gateway.md @@ -0,0 +1,279 @@ +# LLM Gateway Reference + +The Bankr LLM Gateway is a unified API for Claude, Gemini, GPT, and other models. It provides multi-provider access, cost tracking, automatic failover, and SDK compatibility through a single endpoint. + +**Base URL:** `https://llm.bankr.bot` + +The gateway accepts both `https://llm.bankr.bot` and `https://llm.bankr.bot/v1` — it normalizes paths automatically. Works with both OpenAI and Anthropic API formats. + +## Authentication + +The gateway uses your **LLM key** for authentication. The key resolution order: + +1. `BANKR_LLM_KEY` environment variable +2. `llmKey` in `~/.bankr/config.json` +3. Falls back to your Bankr API key (`BANKR_API_KEY` / `apiKey`) + +Most users only need a single key for both the agent API and the LLM gateway. Set a separate LLM key only if your keys have different permissions or rate limits. + +### Setting the LLM Key + +**Via CLI:** +```bash +bankr login --llm-key YOUR_LLM_KEY # during login +bankr config set llmKey YOUR_LLM_KEY # after login +``` + +**Via environment variable:** +```bash +export BANKR_LLM_KEY=your_llm_key_here +``` + +**Verify:** +```bash +bankr config get llmKey +``` + +## Available Models + +| Model | Provider | Best For | +|-------|----------|----------| +| `claude-opus-4.6` | Anthropic | Most capable, advanced reasoning | +| `claude-opus-4.5` | Anthropic | Complex reasoning, architecture | +| `claude-sonnet-4.5` | Anthropic | Balanced speed and quality | +| `claude-haiku-4.5` | Anthropic | Fast, cost-effective | +| `gemini-3-pro` | Google | Long context (2M tokens) | +| `gemini-3-flash` | Google | High throughput | +| `gemini-2.5-pro` | Google | Long context, multimodal | +| `gemini-2.5-flash` | Google | Speed, high throughput | +| `gpt-5.2` | OpenAI | Advanced reasoning | +| `gpt-5.2-codex` | OpenAI | Code generation | +| `gpt-5-mini` | OpenAI | Fast, economical | +| `gpt-5-nano` | OpenAI | Ultra-fast, lowest cost | +| `kimi-k2.5` | Moonshot AI | Long-context reasoning | +| `qwen3-coder` | Alibaba | Code generation, debugging | + +```bash +# Fetch live model list from the gateway +bankr llm models +``` + +## Credits + +Check your LLM gateway credit balance: + +```bash +bankr llm credits +``` + +Returns your remaining USD credit balance. When credits are exhausted, gateway requests will fail with HTTP 402. + +## Tool Integrations + +### OpenClaw + +Auto-install the Bankr provider into your OpenClaw config: + +```bash +# Write config to ~/.openclaw/openclaw.json +bankr llm setup openclaw --install + +# Preview the config without writing +bankr llm setup openclaw +``` + +This writes the following provider config (with your key and all available models): + +```json +{ + "models": { + "providers": { + "bankr": { + "baseUrl": "https://llm.bankr.bot", + "apiKey": "your_key_here", + "api": "openai-completions", + "models": [ + { "id": "claude-sonnet-4.5", "name": "Claude Sonnet 4.5", "api": "anthropic-messages" }, + { "id": "claude-haiku-4.5", "name": "Claude Haiku 4.5", "api": "anthropic-messages" }, + { "id": "gemini-3-flash", "name": "Gemini 3 Flash" }, + { "id": "gpt-5.2", "name": "GPT 5.2" } + ] + } + } + } +} +``` + +Claude models are automatically configured with `"api": "anthropic-messages"` per-model overrides while all other models use the default `"api": "openai-completions"`. + +To use a Bankr model as your default in OpenClaw, add to `openclaw.json`: + +```json +{ + "agents": { + "defaults": { + "model": { + "primary": "bankr/claude-sonnet-4.5" + } + } + } +} +``` + +### Claude Code + +Two ways to use Claude Code with the gateway: + +**Option A: Launch directly (recommended)** + +```bash +# Launch Claude Code through the gateway +bankr llm claude + +# Pass any Claude Code flags through +bankr llm claude --model claude-sonnet-4.5 +bankr llm claude --allowedTools Edit,Write,Bash +bankr llm claude --resume +``` + +All arguments after `claude` are forwarded to the `claude` binary. The CLI sets `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` automatically from your config (using `llmKey` if set, otherwise `apiKey`). + +**Option B: Set environment variables** + +```bash +# Print the env vars to add to your shell profile +bankr llm setup claude +``` + +This outputs: +```bash +export ANTHROPIC_BASE_URL="https://llm.bankr.bot" +export ANTHROPIC_AUTH_TOKEN="your_key_here" +``` + +Add these to `~/.zshrc` or `~/.bashrc` so all Claude Code sessions use the gateway. + +### OpenCode + +```bash +# Auto-install Bankr provider into ~/.config/opencode/opencode.json +bankr llm setup opencode --install + +# Preview without writing +bankr llm setup opencode +``` + +### Cursor + +```bash +# Get step-by-step setup instructions with your API key +bankr llm setup cursor +``` + +The setup adds your key as the OpenAI API Key, sets `https://llm.bankr.bot/v1` as the base URL override, and registers the available model IDs. When the base URL override is enabled, all model requests go through the gateway. + +## Direct SDK Usage + +The gateway is compatible with standard OpenAI and Anthropic SDKs — just override the base URL. + +### curl (OpenAI format) + +```bash +curl -X POST "https://llm.bankr.bot/v1/chat/completions" \ + -H "Authorization: Bearer $BANKR_LLM_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "claude-sonnet-4.5", + "messages": [{"role": "user", "content": "Hello"}] + }' +``` + +### curl (Anthropic format) + +```bash +curl -X POST "https://llm.bankr.bot/v1/messages" \ + -H "x-api-key: $BANKR_LLM_KEY" \ + -H "anthropic-version: 2023-06-01" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "claude-sonnet-4.5", + "max_tokens": 1024, + "messages": [{"role": "user", "content": "Hello"}] + }' +``` + +### OpenAI SDK (Python) + +```python +from openai import OpenAI + +client = OpenAI( + base_url="https://llm.bankr.bot/v1", + api_key="your_bankr_key", +) + +response = client.chat.completions.create( + model="claude-sonnet-4.5", + messages=[{"role": "user", "content": "Hello"}], +) +``` + +### OpenAI SDK (TypeScript) + +```typescript +import OpenAI from "openai"; + +const client = new OpenAI({ + baseURL: "https://llm.bankr.bot/v1", + apiKey: "your_bankr_key", +}); + +const response = await client.chat.completions.create({ + model: "gemini-3-flash", + messages: [{ role: "user", content: "Hello" }], +}); +``` + +### Anthropic SDK (Python) + +```python +from anthropic import Anthropic + +client = Anthropic( + base_url="https://llm.bankr.bot", + api_key="your_bankr_key", +) + +message = client.messages.create( + model="claude-sonnet-4.5", + max_tokens=1024, + messages=[{"role": "user", "content": "Hello"}], +) +``` + +## Troubleshooting + +### 401 Unauthorized +- Verify key is set: `bankr config get llmKey` or `echo $BANKR_LLM_KEY` +- Check for leading/trailing spaces +- Ensure the key hasn't expired + +### 402 Payment Required +- Credits exhausted: `bankr llm credits` shows $0.00 +- Top up credits at [bankr.bot/api](https://bankr.bot/api) + +### Model not found +- Use exact model IDs (e.g., `claude-sonnet-4.5`, not `claude-3-sonnet`) +- Check available models: `bankr llm models` + +### Claude Code not found +- `bankr llm claude` requires Claude Code to be installed separately +- Install: https://docs.anthropic.com/en/docs/claude-code + +### Slow responses +- Try `claude-haiku-4.5` or `gemini-3-flash` for faster responses +- The gateway has automatic failover — temporary slowness usually resolves itself + +--- + +**Documentation**: https://docs.bankr.bot/llm-gateway/overview diff --git a/bankr/scripts/bankr-cancel.sh b/bankr/scripts/bankr-cancel.sh deleted file mode 100755 index 72dcd276..00000000 --- a/bankr/scripts/bankr-cancel.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Cancel a running Bankr job -# Usage: bankr-cancel.sh - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SKILL_DIR="$(dirname "$SCRIPT_DIR")" - -# Find config file -if [ -f "$SKILL_DIR/config.json" ]; then - CONFIG_FILE="$SKILL_DIR/config.json" -elif [ -f "$HOME/.clawdbot/skills/bankr/config.json" ]; then - CONFIG_FILE="$HOME/.clawdbot/skills/bankr/config.json" -else - echo "{\"error\": \"config.json not found\"}" >&2 - exit 1 -fi - -# Extract config -API_KEY=$(jq -r '.apiKey // empty' "$CONFIG_FILE") -API_URL=$(jq -r '.apiUrl // "https://api.bankr.bot"' "$CONFIG_FILE") - -if [ -z "$API_KEY" ]; then - echo "{\"error\": \"apiKey not set in config.json\"}" >&2 - exit 1 -fi - -# Get job ID -JOB_ID="$1" - -if [ -z "$JOB_ID" ]; then - echo "{\"error\": \"Usage: $0 \"}" >&2 - exit 1 -fi - -# Cancel job -curl -sf -X POST "${API_URL}/agent/job/${JOB_ID}/cancel" \ - -H "X-API-Key: ${API_KEY}" \ - -H "Content-Type: application/json" \ - || { - echo "{\"error\": \"Failed to cancel job\"}" >&2 - exit 1 - } diff --git a/bankr/scripts/bankr-status.sh b/bankr/scripts/bankr-status.sh deleted file mode 100755 index 0e6dd27c..00000000 --- a/bankr/scripts/bankr-status.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Check status of a Bankr job -# Usage: bankr-status.sh - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SKILL_DIR="$(dirname "$SCRIPT_DIR")" - -# Find config file -if [ -f "$SKILL_DIR/config.json" ]; then - CONFIG_FILE="$SKILL_DIR/config.json" -elif [ -f "$HOME/.clawdbot/skills/bankr/config.json" ]; then - CONFIG_FILE="$HOME/.clawdbot/skills/bankr/config.json" -else - echo "{\"error\": \"config.json not found\"}" >&2 - exit 1 -fi - -# Extract config -API_KEY=$(jq -r '.apiKey // empty' "$CONFIG_FILE") -API_URL=$(jq -r '.apiUrl // "https://api.bankr.bot"' "$CONFIG_FILE") - -if [ -z "$API_KEY" ]; then - echo "{\"error\": \"apiKey not set in config.json\"}" >&2 - exit 1 -fi - -# Get job ID -JOB_ID="$1" - -if [ -z "$JOB_ID" ]; then - echo "{\"error\": \"Usage: $0 \"}" >&2 - exit 1 -fi - -# Get job status -curl -sf -X GET "${API_URL}/agent/job/${JOB_ID}" \ - -H "X-API-Key: ${API_KEY}" \ - || { - echo "{\"error\": \"Failed to get job status\"}" >&2 - exit 1 - } diff --git a/bankr/scripts/bankr-submit.sh b/bankr/scripts/bankr-submit.sh deleted file mode 100755 index dba5fe38..00000000 --- a/bankr/scripts/bankr-submit.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# Submit a prompt to Bankr Agent API -# Returns job ID for polling - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SKILL_DIR="$(dirname "$SCRIPT_DIR")" - -# Find config file -if [ -f "$SKILL_DIR/config.json" ]; then - CONFIG_FILE="$SKILL_DIR/config.json" -elif [ -f "$HOME/.clawdbot/skills/bankr/config.json" ]; then - CONFIG_FILE="$HOME/.clawdbot/skills/bankr/config.json" -else - echo "{\"error\": \"config.json not found. Create it with your API key from https://bankr.bot/api\"}" >&2 - exit 1 -fi - -# Extract config -API_KEY=$(jq -r '.apiKey // empty' "$CONFIG_FILE") -API_URL=$(jq -r '.apiUrl // "https://api.bankr.bot"' "$CONFIG_FILE") - -if [ -z "$API_KEY" ]; then - echo "{\"error\": \"apiKey not set in config.json\"}" >&2 - exit 1 -fi - -# Get prompt from argument -PROMPT="$*" - -if [ -z "$PROMPT" ]; then - echo "{\"error\": \"Usage: $0 \"}" >&2 - exit 1 -fi - -# Submit prompt -curl -sf -X POST "${API_URL}/agent/prompt" \ - -H "X-API-Key: ${API_KEY}" \ - -H "Content-Type: application/json" \ - -d "$(jq -nc --arg prompt "$PROMPT" '{prompt: $prompt}')" \ - || { - STATUS=$? - if [ $STATUS -eq 22 ]; then - echo "{\"error\": \"API request failed. Check your API key at https://bankr.bot/api\"}" >&2 - else - echo "{\"error\": \"Network error. Please check your connection.\"}" >&2 - fi - exit 1 - } diff --git a/bankr/scripts/bankr.sh b/bankr/scripts/bankr.sh deleted file mode 100755 index f01770d3..00000000 --- a/bankr/scripts/bankr.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# Bankr Agent API wrapper - handles submit-poll-complete workflow -# Usage: bankr.sh - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -# Submit the prompt -SUBMIT_RESULT=$("$SCRIPT_DIR/bankr-submit.sh" "$@") - -# Check if submission succeeded -if ! echo "$SUBMIT_RESULT" | jq -e '.success == true' >/dev/null 2>&1; then - echo "$SUBMIT_RESULT" | jq -r '.error // "Submission failed"' >&2 - exit 1 -fi - -# Extract job ID -JOB_ID=$(echo "$SUBMIT_RESULT" | jq -r '.jobId') - -if [ -z "$JOB_ID" ] || [ "$JOB_ID" = "null" ]; then - echo "Failed to get job ID" >&2 - exit 1 -fi - -echo "Job submitted: $JOB_ID" >&2 -echo "Polling for results..." >&2 - -# Poll for completion (max 5 minutes) -MAX_ATTEMPTS=150 # 150 * 2s = 5 minutes -ATTEMPT=0 - -while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do - sleep 2 - - STATUS_RESULT=$("$SCRIPT_DIR/bankr-status.sh" "$JOB_ID") - - # Get status - STATUS=$(echo "$STATUS_RESULT" | jq -r '.status') - - case "$STATUS" in - "completed") - echo "✓ Job completed" >&2 - echo "$STATUS_RESULT" - exit 0 - ;; - "failed") - ERROR=$(echo "$STATUS_RESULT" | jq -r '.error // "Unknown error"') - echo "✗ Job failed: $ERROR" >&2 - echo "$STATUS_RESULT" - exit 1 - ;; - "cancelled") - echo "✗ Job was cancelled" >&2 - echo "$STATUS_RESULT" - exit 1 - ;; - "pending"|"processing") - # Show status updates if any - UPDATES=$(echo "$STATUS_RESULT" | jq -r '.statusUpdates[]?.message // empty' 2>/dev/null | tail -1) - if [ -n "$UPDATES" ]; then - echo " → $UPDATES" >&2 - fi - ;; - *) - echo "Unknown status: $STATUS" >&2 - ;; - esac - - ATTEMPT=$((ATTEMPT + 1)) -done - -echo "✗ Job timed out after 5 minutes" >&2 -echo "Job ID: $JOB_ID (you can check status manually)" >&2 -exit 1 diff --git a/endaoment/scripts/donate.sh b/endaoment/scripts/donate.sh index c46833fc..35de7b53 100755 --- a/endaoment/scripts/donate.sh +++ b/endaoment/scripts/donate.sh @@ -6,8 +6,11 @@ set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -BANKR_SCRIPT="${BANKR_SCRIPT:-$SCRIPT_DIR/../../bankr/scripts/bankr.sh}" +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 + exit 1 +fi EIN="${1:-}" AMOUNT="${2:-}" @@ -78,7 +81,7 @@ if [[ "$CODE" != "0x" ]] && [[ -n "$CODE" ]]; then echo "📝 Step 1: Approving USDC..." APPROVE_TX="{\"to\": \"$USDC\", \"data\": \"$APPROVE_DATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" - APPROVE_RESULT=$("$BANKR_SCRIPT" "Submit this transaction: $APPROVE_TX" 2>&1) + APPROVE_RESULT=$(bankr prompt "Submit this transaction: $APPROVE_TX" 2>&1) if echo "$APPROVE_RESULT" | grep -q "basescan.org/tx"; then APPROVE_HASH=$(echo "$APPROVE_RESULT" | grep -o 'https://basescan.org/tx/[^ "]*' | head -1) echo " ✅ Approved: $APPROVE_HASH" @@ -92,7 +95,7 @@ if [[ "$CODE" != "0x" ]] && [[ -n "$CODE" ]]; then echo "📝 Step 2: Donating..." DONATE_TX="{\"to\": \"$ENTITY_ADDRESS\", \"data\": \"$DONATE_DATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" - DONATE_RESULT=$("$BANKR_SCRIPT" "Submit this transaction: $DONATE_TX" 2>&1) + DONATE_RESULT=$(bankr prompt "Submit this transaction: $DONATE_TX" 2>&1) if echo "$DONATE_RESULT" | grep -q "basescan.org/tx"; then DONATE_HASH=$(echo "$DONATE_RESULT" | grep -o 'https://basescan.org/tx/[^ "]*' | head -1) echo " ✅ Donated: $DONATE_HASH" @@ -109,7 +112,7 @@ else echo "📝 Step 1: Approving USDC to factory..." APPROVE_TX="{\"to\": \"$USDC\", \"data\": \"$APPROVE_DATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" - APPROVE_RESULT=$("$BANKR_SCRIPT" "Submit this transaction: $APPROVE_TX" 2>&1) + APPROVE_RESULT=$(bankr prompt "Submit this transaction: $APPROVE_TX" 2>&1) if echo "$APPROVE_RESULT" | grep -q "basescan.org/tx"; then APPROVE_HASH=$(echo "$APPROVE_RESULT" | grep -o 'https://basescan.org/tx/[^ "]*' | head -1) echo " ✅ Approved: $APPROVE_HASH" @@ -123,7 +126,7 @@ else echo "📝 Step 2: Deploying & donating..." DEPLOY_TX="{\"to\": \"$FACTORY\", \"data\": \"$DEPLOY_DATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" - DEPLOY_RESULT=$("$BANKR_SCRIPT" "Submit this transaction: $DEPLOY_TX" 2>&1) + DEPLOY_RESULT=$(bankr prompt "Submit this transaction: $DEPLOY_TX" 2>&1) if echo "$DEPLOY_RESULT" | grep -q "basescan.org/tx"; then DEPLOY_HASH=$(echo "$DEPLOY_RESULT" | grep -o 'https://basescan.org/tx/[^ "]*' | head -1) echo " ✅ Deployed & Donated: $DEPLOY_HASH" diff --git a/ens-primary-name/SKILL.md b/ens-primary-name/SKILL.md index acfcdedd..ca1ed0ef 100644 --- a/ens-primary-name/SKILL.md +++ b/ens-primary-name/SKILL.md @@ -13,22 +13,20 @@ A primary name creates a bi-directional link: ## Requirements -### Required: Transaction Signing +### Required: Bankr CLI -This skill requires a way to sign and submit transactions. It looks for the **bankr skill** which provides wallet functionality via the Bankr API. +This skill requires the **Bankr CLI** for transaction signing: -**If you don't have bankr installed:** - -1. Install from: https://github.com/BankrBot/openclaw-skills (bankr skill) -2. Or modify the scripts to use your own transaction submission method +```bash +bun install -g @bankr/cli +bankr login +``` -The scripts call bankr.sh with a prompt like: +The scripts use `bankr prompt` to submit transactions like: ``` Submit this transaction: {"to": "0x...", "data": "0x...", "value": "0", "chainId": 8453} ``` -You can replace the `find_bankr()` function in each script with your own wallet/signer. - ### Required: Node.js Scripts use Node.js with `viem` for ENS namehash calculation and ABI encoding. @@ -112,27 +110,13 @@ Output: | "Transaction reverted" | Ensure the ENS name resolves to your address | | "Name not showing" | Forward resolution may not be set for that chain's cointype | | "Not authorized" | You must call from the address the name resolves to | -| "bankr.sh not found" | Install bankr skill or modify scripts to use your signer | +| "Bankr CLI not found" | Install with `bun install -g @bankr/cli && bankr login` | | "Chain-specific address not set" | Set the address for the target chain via app.ens.domains | | "Could not find resolver" | Ensure the ENS name exists and has a resolver set | -## Customization - -### Using a Different Wallet/Signer - -Replace the `find_bankr()` function in the scripts: - -```bash -# Example: use cast (foundry) instead -send_tx() { - local to="$1" data="$2" chain_id="$3" - cast send "$to" --data "$data" --rpc-url "https://..." --private-key "$PRIVATE_KEY" -} -``` - ## Links - ENS Docs: https://docs.ens.domains/web/reverse - ENS App: https://app.ens.domains - Primary Names UI: https://primary.ens.domains -- Bankr Skill: https://github.com/BankrBot/openclaw-skills +- Bankr CLI: https://www.npmjs.com/package/@bankr/cli diff --git a/ens-primary-name/scripts/set-avatar.sh b/ens-primary-name/scripts/set-avatar.sh index 0512c968..d4c3b29b 100755 --- a/ens-primary-name/scripts/set-avatar.sh +++ b/ens-primary-name/scripts/set-avatar.sh @@ -10,36 +10,14 @@ set -e -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ENS_NAME="${1:?Usage: set-avatar.sh }" AVATAR_URL="${2:?Usage: set-avatar.sh }" -# Find bankr.sh in common locations -# Bankr provides wallet/signing via the Bankr API -# If you don't have bankr, modify this function to use your own signer -find_bankr() { - local locations=( - "$SCRIPT_DIR/../../bankr/scripts/bankr.sh" - "$SCRIPT_DIR/../../moltbot-skills/bankr/scripts/bankr.sh" - "$(command -v bankr.sh 2>/dev/null)" - ) - for loc in "${locations[@]}"; do - if [ -x "$loc" ]; then - echo "$loc" - return 0 - fi - done - echo "ERROR: bankr.sh not found." >&2 - echo "" >&2 - echo "This skill requires a transaction signer. Options:" >&2 - echo "1. Install the bankr skill from https://github.com/BankrBot/openclaw-skills" >&2 - echo "2. Modify find_bankr() in this script to use your own wallet/signer" >&2 - echo "" >&2 - echo "The script needs to submit: {to, data, value, chainId} transactions" >&2 +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 exit 1 -} - -BANKR_SH=$(find_bankr) +fi # Avatars are text records stored on L1 RPC_URL="https://eth.publicnode.com" @@ -107,7 +85,7 @@ echo "Submitting to resolver on Ethereum mainnet..." >&2 echo "⚠️ Note: This requires ETH on mainnet for gas" >&2 # Submit transaction via Bankr -RESULT=$("$BANKR_SH" "Submit this transaction: {\"to\": \"$RESOLVER\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) +RESULT=$(bankr prompt "Submit this transaction: {\"to\": \"$RESOLVER\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) if echo "$RESULT" | grep -q "$EXPLORER"; then TX_HASH=$(echo "$RESULT" | grep -oE "$EXPLORER/tx/0x[a-fA-F0-9]{64}" | grep -oE '0x[a-fA-F0-9]{64}') diff --git a/ens-primary-name/scripts/set-primary.sh b/ens-primary-name/scripts/set-primary.sh index 5004a3ed..21d3c95c 100755 --- a/ens-primary-name/scripts/set-primary.sh +++ b/ens-primary-name/scripts/set-primary.sh @@ -9,32 +9,11 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ENS_NAME="${1:?Usage: set-primary.sh [chain]}" CHAIN="${2:-base}" -# Find bankr.sh in common locations -# Bankr provides wallet/signing via the Bankr API -# If you don't have bankr, modify this function to use your own signer -find_bankr() { - local locations=( - "$SCRIPT_DIR/../../bankr/scripts/bankr.sh" - "$SCRIPT_DIR/../../moltbot-skills/bankr/scripts/bankr.sh" - "$(command -v bankr.sh 2>/dev/null)" - ) - for loc in "${locations[@]}"; do - if [ -x "$loc" ]; then - echo "$loc" - return 0 - fi - done - echo "ERROR: bankr.sh not found." >&2 - echo "" >&2 - echo "This skill requires a transaction signer. Options:" >&2 - echo "1. Install the bankr skill from https://github.com/BankrBot/openclaw-skills" >&2 - echo "2. Modify find_bankr() in this script to use your own wallet/signer" >&2 - echo "" >&2 - echo "The script needs to submit: {to, data, value, chainId} transactions" >&2 +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 exit 1 -} - -BANKR_SH=$(find_bankr) +fi # Reverse Registrar addresses by chain case "$CHAIN" in @@ -145,7 +124,7 @@ console.log(selector + offset + len + data); echo "Calldata: $CALLDATA" >&2 echo "Submitting transaction..." >&2 -RESULT=$("$BANKR_SH" "Submit this transaction: {\"to\": \"$REVERSE_REGISTRAR\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) +RESULT=$(bankr prompt "Submit this transaction: {\"to\": \"$REVERSE_REGISTRAR\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) if echo "$RESULT" | grep -q "$EXPLORER"; then TX_HASH=$(echo "$RESULT" | grep -oE "$EXPLORER/tx/0x[a-fA-F0-9]{64}" | grep -oE '0x[a-fA-F0-9]{64}') diff --git a/erc-8004/scripts/bridge-to-mainnet.sh b/erc-8004/scripts/bridge-to-mainnet.sh index 59a31f79..42f89dcf 100755 --- a/erc-8004/scripts/bridge-to-mainnet.sh +++ b/erc-8004/scripts/bridge-to-mainnet.sh @@ -5,6 +5,12 @@ set -e +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 + exit 1 +fi + AMOUNT="${1:?Usage: bridge-to-mainnet.sh }" echo "=== Bridging ETH to Mainnet ===" >&2 @@ -13,7 +19,7 @@ echo "From: Base" >&2 echo "To: Ethereum Mainnet" >&2 # Use Bankr to bridge -RESULT=$(~/clawd/skills/bankr/scripts/bankr.sh "Bridge $AMOUNT ETH from Base to Ethereum mainnet" 2>/dev/null) +RESULT=$(bankr prompt "Bridge $AMOUNT ETH from Base to Ethereum mainnet" 2>/dev/null) if echo "$RESULT" | grep -qi "success\|bridge\|complete\|transaction"; then echo "=== SUCCESS ===" >&2 diff --git a/erc-8004/scripts/register-http.sh b/erc-8004/scripts/register-http.sh index 6de646bb..1c7969e5 100755 --- a/erc-8004/scripts/register-http.sh +++ b/erc-8004/scripts/register-http.sh @@ -6,6 +6,12 @@ set -e +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 + exit 1 +fi + REGISTRATION_URL="${REGISTRATION_URL:?Error: REGISTRATION_URL environment variable required}" # Check for testnet flag @@ -42,7 +48,7 @@ console.log(selector + offset + len + data); echo "Registering on-chain..." >&2 # Submit via Bankr -RESULT=$(~/clawd/skills/bankr/scripts/bankr.sh "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) +RESULT=$(bankr prompt "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) if echo "$RESULT" | grep -qE "$EXPLORER/tx/0x[a-fA-F0-9]{64}"; then TX_HASH=$(echo "$RESULT" | grep -oE "$EXPLORER/tx/0x[a-fA-F0-9]{64}" | grep -oE '0x[a-fA-F0-9]{64}' | head -1) diff --git a/erc-8004/scripts/register-onchain.sh b/erc-8004/scripts/register-onchain.sh index 3c130ae6..8e9d4fec 100755 --- a/erc-8004/scripts/register-onchain.sh +++ b/erc-8004/scripts/register-onchain.sh @@ -14,6 +14,12 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 + exit 1 +fi + # Check for testnet flag if [ "$1" = "--testnet" ] || [ "$1" = "-t" ]; then CHAIN="sepolia" @@ -56,7 +62,7 @@ echo "Registering on-chain (data URI)..." >&2 echo "Note: This will cost more gas than IPFS/HTTP due to larger calldata" >&2 # Submit via Bankr -RESULT=$(~/clawd/skills/bankr/scripts/bankr.sh "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) +RESULT=$(bankr prompt "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) if echo "$RESULT" | grep -qE "$EXPLORER/tx/0x[a-fA-F0-9]{64}"; then TX_HASH=$(echo "$RESULT" | grep -oE "$EXPLORER/tx/0x[a-fA-F0-9]{64}" | grep -oE '0x[a-fA-F0-9]{64}' | head -1) diff --git a/erc-8004/scripts/register.sh b/erc-8004/scripts/register.sh index 0d6b6cc7..b56509da 100755 --- a/erc-8004/scripts/register.sh +++ b/erc-8004/scripts/register.sh @@ -21,6 +21,12 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 + exit 1 +fi + # Check for testnet flag if [ "$1" = "--testnet" ] || [ "$1" = "-t" ]; then CHAIN="sepolia" @@ -83,7 +89,7 @@ console.log(selector + offset + len + data); echo "Calldata: $CALLDATA" >&2 # Submit via Bankr -RESULT=$(~/clawd/skills/bankr/scripts/bankr.sh "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) +RESULT=$(bankr prompt "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) if echo "$RESULT" | grep -qE "$EXPLORER/tx/0x[a-fA-F0-9]{64}"; then TX_HASH=$(echo "$RESULT" | grep -oE "$EXPLORER/tx/0x[a-fA-F0-9]{64}" | grep -oE '0x[a-fA-F0-9]{64}' | head -1) diff --git a/erc-8004/scripts/update-profile.sh b/erc-8004/scripts/update-profile.sh index 45258d01..c3f97da8 100755 --- a/erc-8004/scripts/update-profile.sh +++ b/erc-8004/scripts/update-profile.sh @@ -5,6 +5,12 @@ set -e +# Require Bankr CLI +if ! command -v bankr >/dev/null 2>&1; then + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli" >&2 + exit 1 +fi + AGENT_ID="${1:?Usage: update-profile.sh [--testnet]}" NEW_URI="${2:?Usage: update-profile.sh [--testnet]}" @@ -55,7 +61,7 @@ console.log(selector + id + offset + len + data); echo "Calldata: $CALLDATA" >&2 # Submit via Bankr -RESULT=$(~/clawd/skills/bankr/scripts/bankr.sh "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) +RESULT=$(bankr prompt "Submit this transaction on $CHAIN: {\"to\": \"$IDENTITY_REGISTRY\", \"data\": \"$CALLDATA\", \"value\": \"0\", \"chainId\": $CHAIN_ID}" 2>/dev/null) if echo "$RESULT" | grep -qE "$EXPLORER/tx/0x[a-fA-F0-9]{64}"; then TX_HASH=$(echo "$RESULT" | grep -oE "$EXPLORER/tx/0x[a-fA-F0-9]{64}" | grep -oE '0x[a-fA-F0-9]{64}' | head -1) diff --git a/veil/scripts/_common.sh b/veil/scripts/_common.sh index b606d8db..3803c8df 100755 --- a/veil/scripts/_common.sh +++ b/veil/scripts/_common.sh @@ -8,7 +8,7 @@ SDK_REPO="${VEIL_SDK_REPO:-$OPENCLAW_WORKSPACE/repos/veildotcash-sdk}" VEIL_DIR="$HOME/.clawdbot/skills/veil" VEIL_ENV="$VEIL_DIR/.env.veil" VEIL_ENV_EXTRA="$VEIL_DIR/.env" # optional (RPC_URL, etc) -BANKR_CONFIG="$HOME/.clawdbot/skills/bankr/config.json" +BANKR_CONFIG="${BANKR_CONFIG:-$HOME/.clawdbot/skills/bankr/config.json}" need_bin() { command -v "$1" >/dev/null 2>&1 || { echo "Missing required binary: $1" >&2; exit 1; } @@ -63,12 +63,22 @@ ensure_veil_env_perms() { [[ -f "$VEIL_ENV_EXTRA" ]] && chmod 600 "$VEIL_ENV_EXTRA" 2>/dev/null || true } -need_bankr_config() { - if [[ ! -f "$BANKR_CONFIG" ]]; then - echo "Bankr config not found at: $BANKR_CONFIG" >&2 - echo "Create it with your Bankr API key (starts with bk_)." >&2 - exit 1 +need_bankr() { + # Prefer Bankr CLI + if command -v bankr >/dev/null 2>&1; then + return 0 + fi + # Fall back to config file for curl-based scripts + if [[ -f "$BANKR_CONFIG" ]]; then + need_bin jq + need_bin curl + return 0 fi - need_bin jq - need_bin curl + echo "Bankr CLI not found. Install with: bun install -g @bankr/cli && bankr login" >&2 + exit 1 +} + +# Legacy alias +need_bankr_config() { + need_bankr } diff --git a/veil/scripts/veil-bankr-prompt.sh b/veil/scripts/veil-bankr-prompt.sh index 38690bde..1d8464f9 100755 --- a/veil/scripts/veil-bankr-prompt.sh +++ b/veil/scripts/veil-bankr-prompt.sh @@ -1,11 +1,12 @@ #!/usr/bin/env bash -# Minimal wrapper: submit a prompt to Bankr Agent API and return final response JSON. +# Submit a prompt to Bankr and return the response. +# Delegates to the Bankr CLI when available, falls back to curl. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/_common.sh" -need_bankr_config +need_bankr PROMPT="$*" if [[ -z "$PROMPT" ]]; then @@ -13,6 +14,12 @@ if [[ -z "$PROMPT" ]]; then exit 1 fi +# CLI path (preferred) — need_bankr already verified one of these is available +if command -v bankr >/dev/null 2>&1; then + exec bankr prompt "$PROMPT" +fi + +# Curl fallback — config file was validated by need_bankr API_KEY=$(jq -r '.apiKey // empty' "$BANKR_CONFIG") API_URL=$(jq -r '.apiUrl // "https://api.bankr.bot"' "$BANKR_CONFIG")