Skip to content

Merit-Systems/OpenClawX402

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenClaw + x402 Sandbox

Run an autonomous AI agent with access to x402 payment APIs (USDC on Base). Works on local machines, EC2, or any remote server.

Paste this into your agent

Read https://github.com/Merit-Systems/OpenClawX402 and help me set up OpenClaw with x402.

Agent Instructions

Be maximally proactive. Do everything on the user's behalf that doesn't require their input. Only ask questions when you genuinely need information you cannot determine yourself.

Step 1: Gather Required Information

Use the AskUserQuestion tool to ask these questions upfront (combine into a single prompt when possible):

  1. Do you already have OpenClaw installed? (Yes / No)
  2. Where is OpenClaw installed (or where do you want to install it)?
    • Local machine (macOS/Linux)
    • AWS EC2 instance
    • Other remote server (VPS, DigitalOcean, etc.)
  3. If yes to #1: What is the path to your OpenClaw installation? (e.g., ~/openclaw, /home/ubuntu/openclaw)

Step 2: Verify and Execute

Once you have the user's answers:

  • Verify the installation by checking for settings.json and .claude/ directory at the provided path
  • Run all commands yourself - don't ask the user to run them unless you cannot (e.g., no SSH access)
  • Install dependencies automatically - mcporter, skills, etc.
  • Create directories and symlinks without asking
  • Only pause for user input when required - e.g., funding the wallet (requires their action), or if a command fails and you need clarification

What NOT to ask about

  • Don't ask permission to install mcporter, skills, or create symlinks - just do it
  • Don't ask which commands to run - execute them based on the user's environment
  • Don't ask the user to copy/paste commands - run them yourself
  • Don't ask for confirmation at each step - proceed through the guide automatically

Prerequisites

Based on the user's answers, they need different prerequisites:

All Users

  1. Telegram bot via BotFather - ./telegram.md
  2. GitHub account for the bot (not your main account) - ./github.md
  3. Anthropic API key from console.anthropic.com

EC2 Users Only

  1. AWS CLI configured with credentials

Local/Other Remote Users

  1. Node.js 18+ installed
  2. Claude Code CLI installed (npm install -g @anthropic-ai/claude-code)

Setup Guides

Guide When to use
./telegram.md All users - Create bot, get token, get your user ID
./github.md All users - Bot GitHub account, token, repo organization
./EC2.md EC2 only - AWS instance, SSH, security group, systemd
./x402.md All users - mcporter, @x402scan/mcp, skills installation

Quick Start by Scenario

Scenario A: Fresh Install on EC2

  1. Complete ./telegram.md
  2. Complete ./github.md
  3. Follow ./EC2.md to provision instance and install Node.js
  4. Run the onboard command (see official docs):
    openclaw onboard --non-interactive --accept-risk \
      --mode local \
      --auth-choice apiKey \
      --anthropic-api-key "$ANTHROPIC_API_KEY" \
      --gateway-port 18789 \
      --gateway-bind loopback \
      --install-daemon \
      --daemon-runtime node
  5. Configure Telegram (see Telegram docs):
    openclaw plugins enable telegram
    openclaw channels add --channel telegram --token "$TELEGRAM_BOT_TOKEN"
    openclaw config set channels.telegram.dmPolicy allowlist
    openclaw config set channels.telegram.allowFrom '[YOUR_TELEGRAM_USER_ID]'
    systemctl --user restart openclaw-gateway
  6. Follow ./x402.md to add x402 support
  7. Message your Telegram bot

Scenario B: Fresh Install on Local Machine

  1. Complete ./telegram.md
  2. Complete ./github.md
  3. Skip EC2.md - Install OpenClaw locally using the official installer:
    # macOS/Linux
    curl -fsSL https://openclaw.ai/install.sh | bash
    
    # Windows (PowerShell)
    iwr -useb https://openclaw.ai/install.ps1 | iex
  4. Run the onboard wizard (see official docs):
    openclaw onboard --install-daemon
    The wizard configures auth, gateway settings, and channels interactively.
  5. Add Telegram channel (if not done during onboard):
    openclaw channels add --channel telegram --token "$TELEGRAM_BOT_TOKEN"
    openclaw pairing list telegram  # See pending pairing requests
  6. Follow ./x402.md to add x402 support
  7. Message your Telegram bot (approve pairing when prompted)

Scenario C: Existing OpenClaw Installation (any environment)

  1. Verify ./telegram.md is complete
  2. Verify ./github.md is complete
  3. Skip to ./x402.md to add x402 support
  4. Message your Telegram bot

Repository Structure

.
├── README.md      # This file - overview and agent instructions
├── telegram.md    # Telegram bot setup via BotFather
├── github.md      # Bot GitHub account and token setup
├── EC2.md         # AWS EC2 instance provisioning (optional)
└── x402.md        # x402 payment integration

Architecture

You (Telegram) --> OpenClaw Host --> Claude API
                        |
                        +--> mcporter --> @x402scan/mcp --> USDC payments

The "OpenClaw Host" can be:

  • Your local machine (macOS/Linux)
  • An EC2 instance
  • Any server with Node.js 18+

Cost

All Environments

  • Anthropic API: pay-per-use
  • x402 calls: pay-per-call (USDC)

EC2 Only

  • EC2 t3.small: ~$15/month
  • EBS 25GB: ~$2/month

Local Machine

  • No hosting costs

Common Issues & Lessons Learned

For Fresh Installs: Read the Official Docs

When installing OpenClaw from scratch, read the official documentation first:

Use the onboard command, not manual configuration

For fresh installs, don't manually configure openclaw.json, systemd services, and gateway tokens piece by piece. The openclaw onboard --non-interactive command handles all of this correctly:

  • Creates proper config structure
  • Sets up gateway authentication
  • Installs the systemd daemon (user-level service)
  • Enables required plugins

Telegram Setup Issues

  1. Add Telegram via CLI: Use the channels CLI to add Telegram:

    openclaw channels add --channel telegram --token "$TELEGRAM_BOT_TOKEN"
  2. Pairing vs Allowlist: By default, dmPolicy: "pairing" requires users to be approved via:

    openclaw pairing list telegram
    openclaw pairing approve telegram <CODE>

    Alternatively, configure allowlist mode via the CLI:

    openclaw configure --section channels
    # Or directly set config values:
    openclaw config set channels.telegram.dmPolicy allowlist
    openclaw config set channels.telegram.allowFrom '[YOUR_TELEGRAM_USER_ID]'
  3. Finding your Telegram User ID (no third-party bot needed):

    # Start the gateway and DM your bot, then check logs:
    openclaw logs --follow
    # Look for "from.id" in the output

    Or message @userinfobot on Telegram.

  4. Restart after config changes: Always restart the gateway after config changes:

    systemctl --user restart openclaw-gateway

Gateway Token Errors

If you see "Gateway auth is set to token, but no token is configured", the gateway will crash-loop. Use the onboard wizard which handles this automatically:

openclaw onboard

If you must manually configure:

openclaw config set gateway.auth.token "$(openssl rand -hex 32)"

Systemd Service Location

The onboard --install-daemon creates a user-level systemd service at:

~/.config/systemd/user/openclaw-gateway.service

Manage it with:

systemctl --user start openclaw-gateway
systemctl --user status openclaw-gateway
journalctl --user -u openclaw-gateway -f

Checking Logs

For detailed logs:

# Systemd logs
journalctl --user -u openclaw-gateway -n 50 --no-pager

# Full log file
tail -100 /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log

# Telegram-specific logs
grep -i telegram /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log | tail -30

About

OpenClaw + x402 setup guide for EC2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •