The Bundler Relay is a secure proxy service that protects the ERC-4337 bundler API key from public exposure while enabling open-source AI agents to submit UserOperations. It acts as an authentication layer between public clients (like the OpenClaw agent) and the private Alchemy bundler infrastructure.
In the Owl Smart Wallet architecture, AI agents cannot directly access the bundler because doing so would require embedding the API key in open-source code. The relay solves this by:
Accepting authenticated requests from verified OpenClaw clients
Injecting the bundler API key from GCP Secret Manager
Forwarding the request to the private bundler endpoint
Returning the response to the client
This architecture enables autonomous agent operation without compromising bundler credentials.
Copy ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ OpenClaw Agent │─────▶│ Bundler Relay │─────▶│ Alchemy Bundler │
│ (Public Code) │ │ (API Key Shield) │ │ (Private) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
GCP Secret Manager
(owl-bundler-api-key) Components:
Public Agent — OpenClaw agent or owl-wallet MCP server with no embedded secrets
Bundler Relay — This service, deployed on Google Cloud Run
Private Bundler — Alchemy ERC-4337 bundler with API key authentication
Secret Manager — GCP service storing the bundler API key
Security Features
The relay implements multiple layers of protection:
Bundler API key stored in GCP Secret Manager, never in code or environment
Requires x-openclaw-client header with valid client identifier
Only ERC-4337 JSON-RPC methods allowed (eth_sendUserOperation, eth_estimateUserOperationGas, etc.)
60 requests/minute per IP address to prevent abuse
Full JSON-RPC 2.0 structure validation before forwarding
30-second timeout with automatic retry on 5xx errors
TLS termination at Cloud Run ingress
Threat Model:
Prevents: API key exposure in public repositories, unauthorized bundler access, method injection attacks
Assumes: GCP infrastructure security, Cloud Run service account permissions properly scoped
Does not protect against: DoS via rate limit exhaustion (mitigated by per-IP limiting)
Returns service health status. Used by Cloud Run for readiness probes.
Response:
Returns service version and build information.
Response:
Forwards ERC-4337 JSON-RPC requests to the bundler with API key injection.
Required Headers:
Header
Required
Description
Client identifier: owl-agent, owl-wallet, openclaw-sdk
Client version in semver format (e.g., 1.0.0)
Request Body (JSON-RPC 2.0):
Allowed Methods:
eth_estimateUserOperationGas
eth_getUserOperationByHash
eth_getUserOperationReceipt
Response:
Proxied response from the bundler, unchanged.
Error Responses:
Missing x-openclaw-client header
Invalid JSON-RPC structure
Rate limit exceeded (60 req/min)
Bundler communication error
Secret Manager unavailable
Local Development
Bundler endpoint (Alchemy or local bundler)
Edit .env :
Note: In local development, the API key is read from .env. In production, it's fetched from GCP Secret Manager.
Production Deployment
GCP project with billing enabled
Cloud Run and Secret Manager APIs enabled
Bundler API key stored in Secret Manager
Deploy to Cloud Run
Environment Variables:
Variable
Description
Example
Base URL of the bundler endpoint
https://eth-mainnet.g.alchemy.com/v2
GCP project ID for Secret Manager
HTTP port (auto-set by Cloud Run)
Verify Deployment
Integration with OpenClaw Agent
The OpenClaw agent's owl-wallet MCP server uses the relay for all bundler interactions:
Key Points:
No API key in agent code — The relay injects it server-side
Automatic retry — The relay handles transient bundler failures
Rate limiting awareness — Agents should implement exponential backoff on 429 responses
Client header required — All requests must identify themselves via x-openclaw-client
Monitoring and Operations
Cloud Run Metrics
Monitor these metrics in GCP Console:
Request count — Track relay usage
Request latency — P50/P95/P99 latencies to bundler
Error rate — 4xx/5xx responses
Instance count — Autoscaling behavior
Secret Rotation
To rotate the bundler API key:
The relay fetches the latest secret version on startup and caches it in memory.
Rate Limit Tuning
To adjust rate limits, modify the RATE_LIMIT_PER_MINUTE environment variable:
Default is 60 requests/minute per IP.
Troubleshooting
400: Missing x-openclaw-client header
Cause: Request missing required authentication header
Solution: Add header to all /rpc requests:
403: Method not allowed
Cause: Attempting to call a non-whitelisted JSON-RPC method
Solution: Only use ERC-4337 bundler methods:
eth_estimateUserOperationGas
eth_getUserOperationByHash
eth_getUserOperationReceipt
429: Rate limit exceeded
Cause: More than 60 requests/minute from the same IP
Solution: Implement exponential backoff in client code:
503: Secret unavailable
Cause: Cloud Run cannot access GCP Secret Manager
Solution: Verify service account permissions:
If missing, grant access: