Build a custom OpenClaw skill that gives your agent a unified capital view across Coinbase, Polymarket, Kalshi, and sportsbook accounts. One SKILL.md file, a few read-only API keys, and your agent can answer “how much do I have?” across every platform in seconds.

Why Your Agent Needs a Wallet Balance Checker

If you’re running an autonomous betting agent, your capital is probably scattered across three or four platforms. $500 in Coinbase waiting to fund a Polymarket position. $200 sitting as USDC on Polygon. $350 in your Kalshi account. Maybe $150 in a sportsbook ledger.

When your agent identifies a +EV opportunity, the first question is: “Do I have capital available on the right platform?” If your agent can’t answer that instantly, it either misses the opportunity or over-allocates because it doesn’t know what’s already deployed.

The wallet-balance-checker skill solves this by giving your agent a single command to query all platforms and return a unified capital view. It’s the foundation of Layer 2 — Wallet in the Agent Betting Stack, sitting between identity (Layer 1) and trading execution (Layer 3).

What You’re Building

The wallet-balance-checker skill teaches your OpenClaw agent four operations:

  1. Check all balances — Query every configured platform and return a unified summary
  2. Check single platform — Query one specific platform (Coinbase, Polymarket, Kalshi, or sportsbook)
  3. Low-balance alerts — Flag any platform below a configurable threshold
  4. Capital allocation summary — Show percentage distribution across platforms

The skill uses curl and jq for API calls, plus inline python3 -c for hex-to-decimal conversion on the Polygon USDC query. Strictly read-only — no trade execution, no fund transfers, no withdrawal capability.

Prerequisites

  • OpenClaw installed and running — Any channel (WhatsApp, Telegram, Discord, WebChat)
  • Coinbase API key — Create at coinbase.com/settings/api with wallet:accounts:read permission only
  • Polymarket wallet address — Your Polygon address that holds USDC (starts with 0x)
  • Kalshi API key — Create at kalshi.com in account settings with read-only scope
  • Polygon RPC endpoint — Free at Alchemy, Infura, or use the public endpoint
  • curl and jq — Pre-installed on macOS and most Linux distributions

The Math Behind Balance Normalization

Each platform reports balances in different units. The skill normalizes everything to USD:

Coinbase returns balances per currency with a native_balance field already in USD. For accounts holding crypto, the API provides the USD-equivalent value at current market prices.

Polymarket balances are USDC on Polygon. The USDC contract uses 6 decimal places, so a raw balance of 500000000 equals $500.00 USDC. The conversion:

USD value = raw_balance / 10^6

The skill queries the USDC contract (0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359) using eth_call to the balanceOf(address) function. The function selector is 0x70a08231 — the first 4 bytes of the keccak256 hash of balanceOf(address).

Kalshi returns balance in cents, so the conversion is:

USD value = balance_cents / 100

Sportsbook ledgers are stored locally as JSON with USD amounts — no conversion needed.

The Complete SKILL.md

Create the skill directory:

mkdir -p ~/.openclaw/skills/wallet-balance-checker

Create ~/.openclaw/skills/wallet-balance-checker/SKILL.md with this content:

---
name: wallet-balance-checker
description: "Check balances across Coinbase, Polymarket (Polygon USDC), Kalshi, and sportsbook accounts. Provides a unified capital view with low-balance alerts. Read-only — never moves funds. Use when asked about balances, capital, wallet status, or fund allocation."
metadata:
  openclaw:
    emoji: "💰"
    requires:
      bins: ["curl", "jq"]
    credentials:
      - id: "coinbase-api-key"
        name: "Coinbase API Key"
        description: "Read-only API key from https://www.coinbase.com/settings/api"
        env: "COINBASE_API_KEY"
      - id: "coinbase-api-secret"
        name: "Coinbase API Secret"
        description: "API secret paired with the Coinbase API key"
        env: "COINBASE_API_SECRET"
      - id: "kalshi-api-key"
        name: "Kalshi API Key"
        description: "Read-only API key from Kalshi account settings"
        env: "KALSHI_API_KEY"
      - id: "polygon-rpc-url"
        name: "Polygon RPC URL"
        description: "Polygon JSON-RPC endpoint (Alchemy, Infura, or public)"
        env: "POLYGON_RPC_URL"
      - id: "polymarket-wallet"
        name: "Polymarket Wallet Address"
        description: "Your 0x Polygon wallet address holding USDC"
        env: "POLYMARKET_WALLET_ADDRESS"
---

# Wallet Balance Checker

Check balances across Coinbase, Polymarket, Kalshi, and sportsbook accounts. Unified capital view. Read-only.

# When to Use

Use this skill when the user asks about:
- Current balances on any platform
- Total available capital across platforms
- Whether they have enough funds for a trade
- Capital allocation or distribution
- Low-balance warnings or alerts
- "How much do I have?"

# CRITICAL: Read-Only Skill

This skill ONLY reads balances. It NEVER:
- Initiates transfers or withdrawals
- Places trades or orders
- Modifies account settings
- Sends funds to any address

If the user asks to move funds, tell them to do it manually or use a dedicated transfer skill with proper security controls.

# Operations

### 1. Check Coinbase Balance

Query all Coinbase accounts and show non-zero balances:

```bash
CB_TIMESTAMP=$(date +%s)
CB_MESSAGE="${CB_TIMESTAMP}GET/v2/accounts"
CB_SIGNATURE=$(echo -n "$CB_MESSAGE" | openssl dgst -sha256 -hmac "$COINBASE_API_SECRET" | cut -d' ' -f2)

curl -s "https://api.coinbase.com/v2/accounts" \
  -H "CB-ACCESS-KEY: $COINBASE_API_KEY" \
  -H "CB-ACCESS-SIGN: $CB_SIGNATURE" \
  -H "CB-ACCESS-TIMESTAMP: $CB_TIMESTAMP" \
  -H "CB-VERSION: 2024-01-01" \
  | jq '[.data[] | select((.balance.amount | tonumber) > 0) | {
    currency: .balance.currency,
    amount: .balance.amount,
    usd_value: .native_balance.amount
  }]'
```

### 2. Check Polymarket Balance (Polygon USDC)

Query on-chain USDC balance. The USDC contract on Polygon is 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359. Function selector for balanceOf(address) is 0x70a08231.

Pad the wallet address to 32 bytes and call:

```bash
PADDED_ADDR=$(echo "$POLYMARKET_WALLET_ADDRESS" | sed 's/0x//' | awk '{printf "%064s", $0}' | tr ' ' '0')

RESULT=$(curl -s -X POST "$POLYGON_RPC_URL" \
  -H "Content-Type: application/json" \
  -d "{
    \"jsonrpc\": \"2.0\",
    \"method\": \"eth_call\",
    \"params\": [{
      \"to\": \"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\",
      \"data\": \"0x70a08231000000000000000000000000${PADDED_ADDR}\"
    }, \"latest\"],
    \"id\": 1
  }" | jq -r '.result')

python3 -c "print(f'Polymarket USDC: ${int(\"$RESULT\", 16) / 1e6:.2f}')"
```

### 3. Check Kalshi Balance

Query Kalshi account balance (returned in cents):

```bash
curl -s "https://api.elections.kalshi.com/trade-api/v2/portfolio/balance" \
  -H "Authorization: Bearer $KALSHI_API_KEY" \
  | jq '{
    available_usd: (.balance / 100),
    reserved_usd: (.portfolio_value / 100)
  }'
```

### 4. Check Local Sportsbook Ledger

If the user maintains a local sportsbook ledger at ~/.openclaw/data/sportsbook-ledger.json:

```bash
if [ -f ~/.openclaw/data/sportsbook-ledger.json ]; then
  jq '{
    total_balance: [.accounts[].balance] | add,
    accounts: [.accounts[] | {name, balance}]
  }' ~/.openclaw/data/sportsbook-ledger.json
else
  echo '{"note": "No sportsbook ledger found. Create one at ~/.openclaw/data/sportsbook-ledger.json"}'
fi
```

Ledger format:
```json
{
  "accounts": [
    {"name": "DraftKings", "balance": 250.00},
    {"name": "FanDuel", "balance": 175.50}
  ]
}
```

### 5. Unified Balance Summary

Run all checks and produce a combined view. Execute operations 1-4 above, then summarize:

- Total capital across all platforms (sum of USD values)
- Per-platform breakdown with percentages
- Flag any platform below the low-balance threshold ($50 default)
- Note any platforms that returned errors or are unconfigured

Format the output as a clean table:

```
Platform        | Balance    | % of Total
----------------|------------|----------
Coinbase        | $1,200.00  | 48.0%
Polymarket      | $500.00    | 20.0%
Kalshi          | $350.00    | 14.0%
DraftKings      | $250.00    | 10.0%
FanDuel         | $200.00    |  8.0%
----------------|------------|----------
TOTAL           | $2,500.00  | 100.0%

⚠️  No platforms below $50 threshold.
```

### 6. Low-Balance Alert Check

Check all platforms against a configurable threshold (default $50):

After running the unified check, flag any platform where the balance is below the threshold. Output format:

```
🚨 LOW BALANCE ALERT
Platform: Kalshi
Balance: $12.50
Threshold: $50.00
Action needed: Fund account before next trade
```

# Output Rules

1. Always show balances in USD with two decimal places
2. For Polymarket, also show the raw USDC amount
3. For Coinbase, list each non-zero currency with its USD equivalent
4. When showing unified view, sort platforms by balance descending
5. Always flag platforms below the low-balance threshold
6. If a platform credential is not configured, skip it with a note rather than failing
7. Never expose API keys, secrets, or full wallet addresses in output — truncate addresses to first 6 and last 4 characters

# Error Handling

- If COINBASE_API_KEY is not set, skip Coinbase and note it as "unconfigured"
- If POLYGON_RPC_URL is not set, use public endpoint https://polygon-rpc.com as fallback
- If KALSHI_API_KEY is not set, skip Kalshi and note it as "unconfigured"
- If the sportsbook ledger file doesn't exist, skip sportsbook and note it
- If any API returns an error, report the error for that platform but continue checking others
- Never let a single platform failure prevent reporting balances for other platforms

Set Your API Keys

# Coinbase — read-only scope
export COINBASE_API_KEY=your_key_here
export COINBASE_API_SECRET=your_secret_here

# Kalshi — read-only scope
export KALSHI_API_KEY=your_key_here

# Polygon RPC — free from Alchemy or Infura
export POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/your_key_here

# Polymarket wallet address
export POLYMARKET_WALLET_ADDRESS=0xYourWalletAddressHere

Add to your shell profile (~/.zshrc, ~/.bashrc) so they persist across sessions:

cat >> ~/.zshrc << 'EOF'
export COINBASE_API_KEY=your_key_here
export COINBASE_API_SECRET=your_secret_here
export KALSHI_API_KEY=your_key_here
export POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/your_key_here
export POLYMARKET_WALLET_ADDRESS=0xYourWalletAddressHere
EOF

OpenClaw reads environment variables from the host process, so the keys are available to the skill automatically.

Security Considerations

This skill handles sensitive financial credentials. A few critical rules:

  • Use read-only API keys everywhere. Coinbase supports scoped keys — grant only wallet:accounts:read. Kalshi supports read-only API tokens. Never give an agent skill withdrawal or transfer permissions.
  • Polymarket doesn’t need an API key. The balance query is an on-chain read against a public contract. Your wallet address is public on the blockchain already, but the skill truncates it in output to avoid unnecessary exposure.
  • Never hardcode credentials in SKILL.md. Use the credentials metadata block and environment variables.
  • The sportsbook ledger is local. It’s a JSON file on your machine — no API calls, no network exposure. Keep it updated manually or via another skill.
  • Read-only by design. This skill cannot move funds even if a malicious prompt tries to make it. The API keys it uses don’t have write permissions, and the skill instructions explicitly prohibit transfer operations.

For a full security framework, see our Agent Security Guide.

Test It

Restart OpenClaw (or wait for hot-reload if your version supports it), then try these prompts:

PromptExpected Behavior
“Check my balances”Runs unified check across all configured platforms
“What’s my Polymarket balance?”Queries Polygon USDC contract for wallet balance
“How much capital do I have?”Full summary with per-platform percentages
“Am I low on any platform?”Checks all platforms against $50 default threshold
“What’s my Coinbase balance?”Lists all non-zero Coinbase account balances in USD
“Kalshi balance”Returns available and reserved balance from Kalshi

Your agent reads the SKILL.md, identifies the relevant operation, and runs the appropriate curl + jq pipeline. For the unified view, it runs all platform checks sequentially and aggregates the results.

How It Works Under the Hood

OpenClaw skills are not plugins that execute code directly. The SKILL.md is a set of instructions that the LLM (Claude, GPT, etc.) reads and follows at runtime.

When you ask “check my balances,” this is what happens:

User message → OpenClaw Gateway
  → LLM reads system prompt + active skills
  → LLM matches "check my balances" to wallet-balance-checker skill
  → LLM runs Coinbase API call with auth headers
  → LLM runs Polygon USDC eth_call for Polymarket
  → LLM runs Kalshi balance API call
  → LLM reads local sportsbook ledger
  → LLM aggregates results into unified table
  → LLM checks thresholds and flags low balances
  → LLM formats output for user

The sequential execution is intentional — each platform query is independent, and the LLM aggregates after all calls complete. If one platform errors, the others still report.

Extending the Skill

Add Cron-Based Low-Balance Alerts

OpenClaw supports cron jobs. Add a scheduled task that checks balances every morning and alerts you if any platform drops below your threshold:

{
  "cron": "0 8 * * *",
  "prompt": "Check all my platform balances. If any platform is below $100, alert me on Telegram with the platform name and current balance."
}

This catches situations where overnight settlement or pending bets have drawn down a platform balance — your agent flags it before you start your next trading session.

Chain with Other Skills

The wallet-balance-checker provides the capital context that other skills need to make decisions:

  • kelly-sizer — Needs your bankroll total to calculate optimal position size. The unified balance feeds Kelly’s bankroll parameter.
  • bankroll-manager — Logs bet outcomes against your actual balances. The balance checker validates that the ledger matches reality.
  • arb-finder — When an arb opportunity spans platforms, needs to know if you have sufficient capital on both sides.
  • cross-market-pricer — Knowing your capital distribution helps prioritize which platform’s prices to act on first.

This is the power of the Agent Betting Stack — composable skills where each layer feeds the next.

Add Historical Balance Tracking

Extend the skill to log daily snapshots to a SQLite database:

{
  "cron": "0 0 * * *",
  "prompt": "Run wallet-balance-checker unified check. Append today's balances to ~/.openclaw/data/balance-history.json with today's date as the key."
}

Over time this builds a capital curve you can chart alongside your P&L from the bankroll-manager skill.

Full Skill Series

This guide is part of the AgentBets OpenClaw Skills series. We’re building a complete library of betting-specific OpenClaw skills that map to the four layers of the Agent Betting Stack:

  • Layer 1 — Identity: Agent reputation tracking via Moltbook
  • Layer 2 — Wallet: Balance checking (this guide), bankroll management, P&L tracking
  • Layer 3 — Trading: Odds scanning, Polymarket monitoring, Kalshi tracking, arbitrage detection
  • Layer 4 — Intelligence: EV calculation, Kelly sizing, CLV tracking, news sentiment

Each skill is a standalone SKILL.md you can install independently or compose into a full autonomous betting pipeline.

What’s Next