$npx -y skills add basezh/agent-skills-on-base --skill elsaOpenClaw skill-pack for Elsa x402 DeFi API integration with micropayments. Enables agents to interact with Elsa DeFi API using x402 payment protocol for USDC micropayments on Base.
| 1 | <p align="center"> |
| 2 | <img src="assets/logo.svg" alt="Elsa + OpenClaw" width="400"> |
| 3 | </p> |
| 4 | |
| 5 | # elsa-openclaw |
| 6 | |
| 7 | OpenClaw skill-pack for Elsa x402 DeFi API integration with micropayments. |
| 8 | |
| 9 | This plugin enables OpenClaw agents to interact with the [Elsa DeFi API](https://x402.heyelsa.ai) using the x402 payment protocol for USDC micropayments on Base. |
| 10 | |
| 11 | ## Security Posture |
| 12 | |
| 13 | - **Non-custodial**: Private keys never leave your machine |
| 14 | - **Local signing**: All transactions are signed locally using viem |
| 15 | - **Budget controls**: Per-call and daily USD limits enforced before any paid API call |
| 16 | - **Execution disabled by default**: Onchain execution tools require explicit opt-in |
| 17 | - **Confirmation tokens**: Dry-run required before confirmed execution (optional but recommended) |
| 18 | - **Separate wallets recommended**: Use different keys for API payments vs. trade execution |
| 19 | |
| 20 | ## Features |
| 21 | |
| 22 | ### Read-Only Tools (Always Available) |
| 23 | - `elsa_search_token` - Search tokens across blockchains |
| 24 | - `elsa_get_token_price` - Get real-time token pricing |
| 25 | - `elsa_get_balances` - Get wallet token balances |
| 26 | - `elsa_get_portfolio` - Comprehensive portfolio analysis |
| 27 | - `elsa_analyze_wallet` - Wallet behavior and risk assessment |
| 28 | - `elsa_get_swap_quote` - Get swap quotes and routing |
| 29 | - `elsa_execute_swap_dry_run` - Simulate swap execution (no onchain action) |
| 30 | - `elsa_budget_status` - Check current budget usage |
| 31 | |
| 32 | ### Execution Tools (Opt-In) |
| 33 | When `ELSA_ENABLE_EXECUTION_TOOLS=true`: |
| 34 | - `elsa_execute_swap_confirmed` - Execute swap with confirmation token |
| 35 | - `elsa_pipeline_get_status` - Check pipeline/transaction status |
| 36 | - `elsa_pipeline_submit_tx_hash` - Submit signed transaction hash |
| 37 | - `elsa_pipeline_run_and_wait` - Orchestrate full pipeline execution |
| 38 | |
| 39 | ## Installation |
| 40 | |
| 41 | ### 1. Clone and install |
| 42 | |
| 43 | ```bash |
| 44 | git clone https://github.com/HeyElsa/elsa-openclaw.git |
| 45 | cd elsa-openclaw |
| 46 | npm install |
| 47 | ``` |
| 48 | |
| 49 | ### 2. Configure OpenClaw |
| 50 | |
| 51 | Edit `~/.openclaw/openclaw.json`: |
| 52 | |
| 53 | ```json |
| 54 | { |
| 55 | "skills": { |
| 56 | "load": { |
| 57 | "extraDirs": ["/path/to/elsa-openclaw"] |
| 58 | }, |
| 59 | "entries": { |
| 60 | "openclaw-elsa-x402": { |
| 61 | "env": { |
| 62 | "PAYMENT_PRIVATE_KEY": "0x_YOUR_WALLET_PRIVATE_KEY" |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | ``` |
| 69 | |
| 70 | **Minimal config** - only `PAYMENT_PRIVATE_KEY` is required. All other settings have sensible defaults. |
| 71 | |
| 72 | **With execution enabled** (for swaps): |
| 73 | ```json |
| 74 | { |
| 75 | "skills": { |
| 76 | "load": { |
| 77 | "extraDirs": ["/path/to/elsa-openclaw"] |
| 78 | }, |
| 79 | "entries": { |
| 80 | "openclaw-elsa-x402": { |
| 81 | "env": { |
| 82 | "PAYMENT_PRIVATE_KEY": "0x...", |
| 83 | "TRADE_PRIVATE_KEY": "0x...", |
| 84 | "ELSA_ENABLE_EXECUTION_TOOLS": "true" |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | ``` |
| 91 | |
| 92 | ### 3. Fund your payment wallet |
| 93 | |
| 94 | The payment wallet needs USDC on Base to pay for API calls (~$0.01-0.05 per call). |
| 95 | |
| 96 | ### 4. Restart OpenClaw |
| 97 | |
| 98 | The skill will load automatically. Verify with `/skills` in chat. |
| 99 | |
| 100 | ## Usage in OpenClaw |
| 101 | |
| 102 | Once configured, just talk naturally: |
| 103 | |
| 104 | | You say | Tool used | |
| 105 | |---------|-----------| |
| 106 | | "What's the price of WETH?" | `elsa_get_token_price` | |
| 107 | | "Search for PEPE token" | `elsa_search_token` | |
| 108 | | "Show portfolio for 0xd8dA..." | `elsa_get_portfolio` | |
| 109 | | "Get a quote to swap 10 USDC to WETH" | `elsa_get_swap_quote` | |
| 110 | | "How much have I spent on Elsa API?" | `elsa_budget_status` | |
| 111 | | "Swap 10 USDC to WETH on Base" | Full swap flow (with execution enabled) | |
| 112 | |
| 113 | ## Smoke Test |
| 114 | |
| 115 | After installation, verify the setup: |
| 116 | |
| 117 | ```bash |
| 118 | # Search for a token |
| 119 | npx tsx scripts/index.ts elsa_search_token '{"query": "USDC", "limit": 3}' |
| 120 | |
| 121 | # Get portfolio for a sample address |
| 122 | npx tsx scripts/index.ts elsa_get_portfolio '{"wallet_address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"}' |
| 123 | |
| 124 | # Check budget status |
| 125 | npx tsx scripts/index.ts elsa_budget_status '{}' |
| 126 | ``` |
| 127 | |
| 128 | > **Field Mapping Note**: This skill uses `wallet_address` in tool inputs, which maps internally to Elsa API's `evm_address` field. |
| 129 | |
| 130 | Expected output includes: |
| 131 | - `ok: true` for successful calls |
| 132 | - `billing: { estimated_cost_usd, ... }` showing API cost |
| 133 | - `meta: { latency_ms, ... }` with request metadata |
| 134 | |
| 135 | ## Enabling Execution Tools |
| 136 | |
| 137 | **WARNING**: Execution tools perform real onchain transactions. |
| 138 | |
| 139 | ```bash |
| 140 | # Required for x402 API payments |
| 141 | PAYMENT_PRIVATE_KEY=0x... |
| 142 | |
| 143 | # Required for signing swap transactions (falls back to PAYMENT_PRIVATE_KEY if not set) |
| 144 | TRADE_PRIVATE_KEY=0x... |
| 145 | |
| 146 | # Enable execution tools |
| 147 | ELSA_ENABLE_EXECUTION_TOOLS=true |
| 148 | ``` |
| 149 | |
| 150 | 1. Set `ELSA_ENABLE_EXECUTION_TOOLS=true` |
| 151 | 2. Ensure `TRADE_PRIVATE_KEY` has sufficient funds for gas and swaps |
| 152 | 3. Recommended: Use separate wallets for payments vs. trading |
| 153 | |
| 154 | ### Recommended Swap Flow |
| 155 | |
| 156 | ``` |
| 157 | ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────┐ ┌─────────────────────┐ |
| 158 | │ 1. Get Quote │ ──▶ │ 2. Dry Run │ ──▶ │ 3. Confirm │ ──▶ │ |