Get the FREE Ultimate OpenClaw Setup Guide →
R

Lightning Agentic Commerce

Scanned

@Roasbeef

npx machina-cli add skill @Roasbeef/lightning-agent-commerce --openclaw
Files (1)
SKILL.md
5.7 KB

Agentic Commerce Toolkit

This plugin provides a complete toolkit for agent-driven Lightning Network commerce. Three skills work together to enable agents to send and receive micropayments over the Lightning Network using the L402 protocol.

Components

SkillPurpose
lndRun Lightning Terminal (litd: lnd + loop + pool + tapd)
lngetFetch L402-protected resources (pay for data)
apertureHost paid API endpoints (sell data)

Full Setup Workflow

Step 1: Install All Components

# Install litd (Lightning Terminal — bundles lnd + loop + pool + tapd)
skills/lnd/scripts/install.sh

# Install lnget (Lightning HTTP client)
skills/lnget/scripts/install.sh

# Install aperture (L402 reverse proxy)
skills/aperture/scripts/install.sh

Step 2: Set Up the Lightning Node

# Start litd container (testnet by default)
skills/lnd/scripts/start-lnd.sh

# Create an encrypted wallet
skills/lnd/scripts/create-wallet.sh --mode standalone

# Verify node is running
skills/lnd/scripts/lncli.sh getinfo

Step 3: Fund the Wallet

# Generate a Bitcoin address
skills/lnd/scripts/lncli.sh newaddress p2tr

# Send BTC to this address from an exchange or another wallet

# Verify balance
skills/lnd/scripts/lncli.sh walletbalance

Step 4: Open a Channel

# Connect to a well-connected node (e.g., ACINQ, Bitfinex)
skills/lnd/scripts/lncli.sh connect <pubkey>@<host>:9735

# Open a channel
skills/lnd/scripts/lncli.sh openchannel --node_key=<pubkey> --local_amt=1000000

# Wait for channel to confirm (6 blocks)
skills/lnd/scripts/lncli.sh listchannels

Step 5: Configure lnget

# Initialize lnget config (auto-detects local lnd)
lnget config init

# Verify connection
lnget ln status

Step 6: Fetch Paid Resources

# Fetch an L402-protected resource
lnget --max-cost 1000 https://api.example.com/paid-data

# Preview without paying
lnget --no-pay https://api.example.com/paid-data

# Check cached tokens
lnget tokens list

Step 7: Host Paid Endpoints (Optional)

# Start your backend service
python3 -m http.server 8080 &

# Configure aperture to protect it
skills/aperture/scripts/setup.sh --insecure --port 8081

# Start the L402 paywall
skills/aperture/scripts/start.sh

# Other agents can now pay to access your endpoints
# lnget --max-cost 100 https://your-host:8081/api/data

Agent-to-Agent Commerce

The full loop for autonomous agent commerce:

Agent A (buyer)                    Agent B (seller)
─────────────                      ─────────────
lnd node running                   lnd node running
  ↓                                  ↓
lnget fetches URL ──────────────→ aperture receives request
                                     ↓
                                   Returns 402 + invoice
  ↓
lnget pays invoice ─────────────→ lnd receives payment
  ↓                                  ↓
lnget retries with token ───────→ aperture validates token
                                     ↓
                                   Proxies to backend
  ↓                                  ↓
Agent A receives data ←──────────  Backend returns data

Buyer Agent Setup

# One-time setup
skills/lnd/scripts/install.sh
skills/lnget/scripts/install.sh
skills/lnd/scripts/start-lnd.sh
skills/lnd/scripts/create-wallet.sh --mode standalone
lnget config init

# Fund wallet and open channels (one-time)
skills/lnd/scripts/lncli.sh newaddress p2tr
# ... send BTC ...
skills/lnd/scripts/lncli.sh openchannel --node_key=<pubkey> --local_amt=500000

# Ongoing: fetch paid resources
lnget --max-cost 100 -q https://seller-api.example.com/api/data | jq .

Seller Agent Setup

# One-time setup
skills/lnd/scripts/install.sh
skills/aperture/scripts/install.sh
skills/lnd/scripts/start-lnd.sh
skills/lnd/scripts/create-wallet.sh --mode standalone

# Configure and start paywall
skills/aperture/scripts/setup.sh --port 8081 --insecure

# Start backend with content to sell
mkdir -p /tmp/api-data
echo '{"market_data": "..."}' > /tmp/api-data/data.json
cd /tmp/api-data && python3 -m http.server 8080 &

# Start aperture
skills/aperture/scripts/start.sh

# Buyers can now access:
# https://your-host:8081/api/data.json (100 sats per request)

Cost Management

Agents should always control spending:

# Set a hard limit per request
lnget --max-cost 500 https://api.example.com/data

# Check cost before paying
lnget --no-pay --json https://api.example.com/data | jq '.invoice_amount_sat'

# Track spending via token list
lnget tokens list --json | jq '[.[] | .amount_paid_sat] | add'

Security Summary

ComponentSecurity Model
Wallet passphraseStored at ~/.lnget/lnd/wallet-password.txt (0600)
Seed mnemonicStored at ~/.lnget/lnd/seed.txt (0600)
L402 tokensStored at ~/.lnget/tokens/<domain>/ per domain
lnd macaroonsStandard lnd paths at ~/.lnd/data/chain/...
Aperture DBSQLite at ~/.aperture/aperture.db

For production use with significant funds, use watch-only mode with a remote signer container. See the lightning-security-module skill for details.

Stopping Everything

skills/aperture/scripts/stop.sh
skills/lnd/scripts/stop-lnd.sh

Source

git clone https://clawhub.ai/Roasbeef/lightning-agent-commerceView on GitHub

Overview

Agentic Commerce Toolkit enables end-to-end Lightning Network payments for agents. It combines lnd, lnget, and aperture to let agents send and receive micropayments, fetch paid resources, and host paid API endpoints using L402. This enables autonomous agent-to-agent data transactions and a complete paid-resource workflow.

How This Skill Works

Install and run a full payment stack (lnd via litd, lnget for paid data, aperture for paywalled endpoints). lnget handles paid-resource fetches against L402 invoices, while aperture protects endpoints behind the L402 paywall. The end-to-end loop supports agent-to-agent commerce by exchanging invoices, tokens, and proxied data.

When to Use It

  • To deploy a full Lightning payment stack (lnd + lnget + aperture) for agentic commerce
  • To buy data or pay for a paid resource via L402
  • To host paid data endpoints and monetize API access with L402 paywalls
  • To enable autonomous agent-to-agent micropayments within workflows
  • To run an end-to-end buyer-seller data exchange loop between agents

Quick Start

  1. Step 1: Install and launch all components (lnd, lnget, aperture)
  2. Step 2: Set up your Lightning node, fund the wallet, and open a channel
  3. Step 3: Configure lnget and test paying for a resource or hosting an endpoint

Best Practices

  • Install all components (lnd, lnget, aperture) together and keep them compatible
  • Set up and test on testnet: start litd, create a wallet, and open channels
  • Configure lnget, verify connection, and manage paid resources with tokens
  • Protect endpoints with aperture and validate L402 paywall flows
  • Test end-to-end (buyer and seller) including retries and token validation

Example Use Cases

  • A buyer agent fetches an L402-protected dataset from a seller API behind a paywall using lnget
  • A seller agent hosts a paid API endpoint behind an L402 paywall via aperture
  • Two agents perform autonomous micropayments for a micro-task and exchange data
  • A complete testnet deployment of lnd, lnget, and aperture to simulate real commerce
  • Preview paid data without paying using lnget --no-pay to verify content

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers