$npx -y skills add lightninglabs/lightning-agent-tools --skill commerceEnd-to-end agentic commerce workflow using Lightning Network. Use when an agent needs to set up a full payment stack (lnd + lnget + aperture), buy or sell data via L402, or enable agent-to-agent micropayments.
| 1 | # Agentic Commerce Toolkit |
| 2 | |
| 3 | This plugin provides a complete toolkit for agent-driven Lightning Network |
| 4 | commerce. Three skills work together to enable agents to send and receive |
| 5 | micropayments over the Lightning Network using the L402 protocol. |
| 6 | |
| 7 | ## Components |
| 8 | |
| 9 | | Skill | Purpose | |
| 10 | |-------|---------| |
| 11 | | **lnd** | Run Lightning Terminal (litd: lnd + loop + pool + tapd) | |
| 12 | | **lnget** | Fetch L402-protected resources (pay for data) | |
| 13 | | **aperture** | Host paid API endpoints (sell data) | |
| 14 | |
| 15 | ## Full Setup Workflow |
| 16 | |
| 17 | ### Step 1: Install All Components |
| 18 | |
| 19 | ```bash |
| 20 | # Install litd (Lightning Terminal — bundles lnd + loop + pool + tapd) |
| 21 | skills/lnd/scripts/install.sh |
| 22 | |
| 23 | # Install lnget (Lightning HTTP client) |
| 24 | skills/lnget/scripts/install.sh |
| 25 | |
| 26 | # Install aperture (L402 reverse proxy) |
| 27 | skills/aperture/scripts/install.sh |
| 28 | ``` |
| 29 | |
| 30 | ### Step 2: Set Up the Lightning Node |
| 31 | |
| 32 | ```bash |
| 33 | # Start litd container (testnet by default) |
| 34 | skills/lnd/scripts/start-lnd.sh |
| 35 | |
| 36 | # Create an encrypted wallet |
| 37 | skills/lnd/scripts/create-wallet.sh --mode standalone |
| 38 | |
| 39 | # Verify node is running |
| 40 | skills/lnd/scripts/lncli.sh getinfo |
| 41 | ``` |
| 42 | |
| 43 | ### Step 3: Fund the Wallet |
| 44 | |
| 45 | ```bash |
| 46 | # Generate a Bitcoin address |
| 47 | skills/lnd/scripts/lncli.sh newaddress p2tr |
| 48 | |
| 49 | # Send BTC to this address from an exchange or another wallet |
| 50 | |
| 51 | # Verify balance |
| 52 | skills/lnd/scripts/lncli.sh walletbalance |
| 53 | ``` |
| 54 | |
| 55 | ### Step 4: Open a Channel |
| 56 | |
| 57 | ```bash |
| 58 | # Connect to a well-connected node (e.g., ACINQ, Bitfinex) |
| 59 | skills/lnd/scripts/lncli.sh connect <pubkey>@<host>:9735 |
| 60 | |
| 61 | # Open a channel |
| 62 | skills/lnd/scripts/lncli.sh openchannel --node_key=<pubkey> --local_amt=1000000 |
| 63 | |
| 64 | # Wait for channel to confirm (6 blocks) |
| 65 | skills/lnd/scripts/lncli.sh listchannels |
| 66 | ``` |
| 67 | |
| 68 | ### Step 5: Configure lnget |
| 69 | |
| 70 | ```bash |
| 71 | # Initialize lnget config (auto-detects local lnd) |
| 72 | lnget config init |
| 73 | |
| 74 | # Verify connection |
| 75 | lnget ln status |
| 76 | ``` |
| 77 | |
| 78 | ### Step 6: Fetch Paid Resources |
| 79 | |
| 80 | ```bash |
| 81 | # Fetch an L402-protected resource |
| 82 | lnget --max-cost 1000 https://api.example.com/paid-data |
| 83 | |
| 84 | # Preview without paying |
| 85 | lnget --no-pay https://api.example.com/paid-data |
| 86 | |
| 87 | # Check cached tokens |
| 88 | lnget tokens list |
| 89 | ``` |
| 90 | |
| 91 | ### Step 7: Host Paid Endpoints (Optional) |
| 92 | |
| 93 | ```bash |
| 94 | # Start your backend service |
| 95 | python3 -m http.server 8080 & |
| 96 | |
| 97 | # Configure aperture to protect it |
| 98 | skills/aperture/scripts/setup.sh --insecure --port 8081 |
| 99 | |
| 100 | # Start the L402 paywall |
| 101 | skills/aperture/scripts/start.sh |
| 102 | |
| 103 | # Other agents can now pay to access your endpoints |
| 104 | # lnget --max-cost 100 https://your-host:8081/api/data |
| 105 | ``` |
| 106 | |
| 107 | ## Agent-to-Agent Commerce |
| 108 | |
| 109 | The full loop for autonomous agent commerce: |
| 110 | |
| 111 | ``` |
| 112 | Agent A (buyer) Agent B (seller) |
| 113 | ───────────── ───────────── |
| 114 | lnd node running lnd node running |
| 115 | ↓ ↓ |
| 116 | lnget fetches URL ──────────────→ aperture receives request |
| 117 | ↓ |
| 118 | Returns 402 + invoice |
| 119 | ↓ |
| 120 | lnget pays invoice ─────────────→ lnd receives payment |
| 121 | ↓ ↓ |
| 122 | lnget retries with token ───────→ aperture validates token |
| 123 | ↓ |
| 124 | Proxies to backend |
| 125 | ↓ ↓ |
| 126 | Agent A receives data ←────────── Backend returns data |
| 127 | ``` |
| 128 | |
| 129 | ### Buyer Agent Setup |
| 130 | |
| 131 | ```bash |
| 132 | # One-time setup |
| 133 | skills/lnd/scripts/install.sh |
| 134 | skills/lnget/scripts/install.sh |
| 135 | skills/lnd/scripts/start-lnd.sh |
| 136 | skills/lnd/scripts/create-wallet.sh --mode standalone |
| 137 | lnget config init |
| 138 | |
| 139 | # Fund wallet and open channels (one-time) |
| 140 | skills/lnd/scripts/lncli.sh newaddress p2tr |
| 141 | # ... send BTC ... |
| 142 | skills/lnd/scripts/lncli.sh openchannel --node_key=<pubkey> --local_amt=500000 |
| 143 | |
| 144 | # Ongoing: fetch paid resources |
| 145 | lnget --max-cost 100 -q https://seller-api.example.com/api/data | jq . |
| 146 | ``` |
| 147 | |
| 148 | ### Seller Agent Setup |
| 149 | |
| 150 | ```bash |
| 151 | # One-time setup |
| 152 | skills/lnd/scripts/install.sh |
| 153 | skills/aperture/scripts/install.sh |
| 154 | skills/lnd/scripts/start-lnd.sh |
| 155 | skills/lnd/scripts/create-wallet.sh --mode standalone |
| 156 | |
| 157 | # Configure and start paywall |
| 158 | skills/aperture/scripts/setup.sh --port 8081 --insecure |
| 159 | |
| 160 | # Start backend with content to sell |
| 161 | mkdir -p /tmp/api-data |
| 162 | echo '{"market_data": "..."}' > /tmp/api-data/data.json |
| 163 | cd /tmp/api-data && python3 -m http.server 8080 & |
| 164 | |
| 165 | # Start aperture |
| 166 | skills/aperture/scripts/start.sh |
| 167 | |
| 168 | # Buyers can now access: |
| 169 | # https://your-host:8081/api/data.json (100 sats per request) |
| 170 | ``` |
| 171 | |
| 172 | ## Cost Management |
| 173 | |
| 174 | Agents should always control spending: |
| 175 | |
| 176 | ```bash |
| 177 | # Set a hard limit per request |
| 178 | lnget --max-cost 500 https://api.example.com/data |
| 179 | |
| 180 | # Check cost before paying |
| 181 | lnget --no-pay --json https://api.example.com/data | jq '.invoice_amount_sat' |
| 182 | |
| 183 | # Track spending via token list |
| 184 | lnget tokens list --json | jq '[.[] | .amount_paid_sat] | add' |
| 185 | ``` |
| 186 | |
| 187 | ## Security Summary |
| 188 | |
| 189 | | Component | Security Model | |
| 190 | |-- |