# Environment Variables

All secrets are stored as Convex environment variables — never in the frontend bundle or MCP server.

***

## Set via CLI

```bash
# Run from the app/ folder (where convex/ is)
npx convex env set KEY_NAME "value"
```

Or go to **Convex Dashboard → your deployment → Settings → Environment Variables**.

***

## Required Variables

| Variable                | Purpose                                                                             | Where to Get                    |
| ----------------------- | ----------------------------------------------------------------------------------- | ------------------------------- |
| `BANKR_API_KEY`         | Bankr LLM and Agent API for all agents, signals, and whale tracking                 | bankr.bot dashboard             |
| `TELEGRAM_BOT_TOKEN`    | Default bot token for sending signals, whale alerts, and research reports           | @BotFather on Telegram          |
| `TELEGRAM_CHAT_ID`      | Default chat ID for Telegram delivery                                               | Your Telegram chat/group ID     |
| `GROK_API_KEY`          | Grok API for X/Twitter sentiment analysis                                           | console.x.ai                    |
| `WALLET_ENCRYPTION_KEY` | AES-256 key used to encrypt/decrypt user private keys in the DB — never expose this | Generate a strong random string |
| `ZX_API_KEY`            | 0x API key for Permit2 swap quotes on Base mainnet                                  | dashboard.0x.org                |

***

## Optional Variables

| Variable              | Purpose                                                    | Default                                     |
| --------------------- | ---------------------------------------------------------- | ------------------------------------------- |
| `BASE_RPC_URL`        | RPC endpoint for Base mainnet transaction signing          | `https://mainnet.base.org`                  |
| `LLM_ENDPOINT`        | Override Bankr LLM gateway URL                             | `https://llm.bankr.bot/v1/chat/completions` |
| `NOEL_WALLET_ADDRESS` | Noelclaw platform wallet for USDC deposits (x402 endpoint) | —                                           |

> **Wallet security:** `WALLET_ENCRYPTION_KEY` must be set before any user calls `get_portfolio`, `swap_tokens`, or `send_token`. Private keys are AES-256-CBC encrypted before storage — the plaintext key never touches the database.

> **Per-user Telegram:** Users can set their own bot token and chat ID via `set_telegram` MCP tool or `POST /user/telegram`. When set, their personal bot is used instead of the default.

***

## MCP Server Variable

The MCP server only needs one optional env var:

| Variable              | Purpose                        | Default                                 |
| --------------------- | ------------------------------ | --------------------------------------- |
| `NOELCLAW_CONVEX_URL` | Override Convex deployment URL | `https://valuable-fish-533.convex.site` |

Set this when adding the MCP server to any client:

```json
"env": {
  "NOELCLAW_CONVEX_URL": "https://valuable-fish-533.convex.site"
}
```

***

## Frontend Variables (Vite)

These go in `app/.env` or `app/.env.local`:

| Variable            | Purpose                                              |
| ------------------- | ---------------------------------------------------- |
| `VITE_CONVEX_URL`   | Convex deployment URL for frontend                   |
| `VITE_PRIVY_APP_ID` | Privy app ID for authentication (frontend auth only) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.noelclaw.fun/backend-and-api/env-vars.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
