Skip to main content

satsgate

Charge AI agents in Lightning and USDC on the same 402. Payments go straight to your wallet. 500 free unlocks a month.

No node to run, and no custody: the buyer pays the seller's wallet. After 500 free unlocks in a UTC month, each paid unlock debits 2 sats from a prepaid service balance, capped at 10% of the item price.

satsgate init takes a merchant from nothing to a self-hosted paywall config. It opens a free account, saves the account key in .satsgate/account.env, asks for a Lightning Address, mints a restricted proxy key, writes .env and satsgate-proxy.yaml, and checks the paywall with a real 402. That check does not pay, verify, or settle. It also reads whether the Lightning Address advertises LUD-21 verify.

Terms: https://satsgate.org/terms. Source: https://github.com/Mike-io-hash/satsgate. API reference: https://github.com/Mike-io-hash/satsgate/blob/main/docs/api.md.

It does not ask for a seed, a private key, or a recovery phrase. It does not hold sats or USDC. The account key is not copied into the project .env. The project .env holds SATSGATE_API_KEY (sgr_) and SATSGATE_ORIGIN_SECRET.

uvx satsgate init

or pip install satsgate, then satsgate init.

Three commands:

  • satsgate try pays a demo paywall once, to your own Lightning Address, so you see a real 402 paid and unlocked before you configure anything of your own.
  • satsgate init writes the config for your API or your remote MCP server.
  • satsgate status reads the setup back.

Try it

Once you have a Lightning Address, this takes about five minutes:

uvx satsgate try

try opens or reuses the free account in .satsgate/, sets your Lightning Address, and mints a restricted key for this run only. A demo origin, the proxy, and a buyer run in the same process. Nothing listens on a port. The buyer asks GET /hello, gets a 402 for 10 sats (--sats sets 1 to 1000), and the terminal shows the invoice and a QR a phone camera can scan (--no-qr hides it).

The payment is real. The sats go to your own Lightning Address. Pay from a different wallet than the one behind that address, because some wallets cannot pay their own invoice. When the address advertises LUD-21 verify, try sees the payment by itself. Otherwise it asks for the payment preimage from the paying wallet. After the unlock it prints the demo response and the free unlocks left this month, then revokes the restricted key. It writes only under .satsgate/.

An agent cannot scan a QR for its owner. It gets the invoice and checks later:

satsgate try --json --no-wait --lightning-address merchant@pay.example
satsgate try --check <payment_hash> --json
satsgate try --check <payment_hash> --preimage <hex> --json

--no-wait never prompts, even on a terminal. It returns status awaiting_payment, the challenge (invoice, payment_hash, invoice_expires_at), and a check_command. The macaroon stays in .satsgate/try.json and is not printed. --check reads the status once. While the invoice is unpaid it returns pending (with retry_after_seconds), expired, preimage_required, or preimage_rejected, and it does not mint a key or use a free unlock. A confirmed payment whose access window ended before it was unlocked returns expired with unlock_window_ended. Nothing is minted or debited. Once the payment is confirmed, --check sends one GET /hello through the same in-process proxy as interactive mode, prints the demo origin's response, and uses one free unlock. The core debits that unlock only after the origin answers 2xx, and only once for that payment. A repeat check returns the saved response with already_unlocked: true and uses nothing more. The core, not the local file, decides that the payment was already unlocked.

schema_version stays 1 and status stays paid. Inside paid: seconds (a number, or null on a repeat check), origin_response (the demo origin's JSON), unlocked (true after a confirmed check or an interactive unlock), already_unlocked (true when this payment was already unlocked), and free_unlocks_left (an integer, or null when the quota was not read or was not saved). Interactive mode uses the same paid fields. .satsgate/try.json gains unlocked, with origin_response, free_unlocks_left, and unlocked_at. A file written by 0.2.0, without unlocked, still unlocks once. If the unlock succeeded and that record was not saved, a later check returns paid with origin_response: null, free_unlocks_left: null, and the warning origin_response_not_saved. With --json and without --no-wait, try waits for the payment when the address advertises LUD-21 verify and prints the invoice on stderr; otherwise it returns like --no-wait.

API or MCP

Human mode asks what you are charging for. Agent mode defaults to --kind api.

satsgate init --json --lightning-address merchant@pay.example --kind mcp --paid-tool deep_search=21

--kind mcp writes one route with methods: [POST, DELETE] on --mcp-path (default /mcp), signal: in_band, default: free, and one entry per --paid-tool NAME=SATS. Only those tools are charged; every other MCP message is forwarded free. The upstream default is http://127.0.0.1:8000. Without --paid-tool, the route uses example_tool at 10 sats and warns example_tool_placeholder. The check is an unpaid tools/call through the in-memory proxy, and route in the JSON lists the tools. The resource of a paid tool is route:mcp:<tool>.

Lightning Address

When the Lightning Address is missing, or does not advertise LUD-21 verify, init and try list providers that advertised LUD-21 verify on a given date. Human mode prints the list. Agent mode adds address_options (checked_on, providers) and a next_steps line. The list is alphabetical and is not an endorsement. It can change: the live check on your own address is what counts. In human mode, init offers to try another address after a negative check, up to three times. The YAML does not change.

Status

satsgate status
satsgate status --json
satsgate status --check-address

status shows the account (key_preview and fingerprint, never the key), the Lightning Address, the last LUD-21 check from .satsgate/last-check.json, the free unlocks left and when they reset, the prepaid balance, paid unlocks in the last 24 hours, the routes from satsgate-proxy.yaml with USDC on or off, and whether the proxy answers GET /healthz on its local address. --check-address checks the address again with one unpaid invoice; nothing is paid or debited. --config reads another YAML. Exit codes: 0 fine, 1 the API or the network failed, 2 usage (for example no account here), 3 something needs a decision (no address, an address without LUD-21 verify, a suspended account, USDC on a route without a verified EVM payee, or a rejected key).

Human and agent

Human mode prompts when stdin is a terminal and --json is not set. It asks what you are charging for (API or MCP) and the Lightning Address. With MCP it also asks for the tool to charge for and its price. USDC test mode and the origin snippet are flags (--want-usdc, --framework). Agent mode (--json, or stdin that is not a terminal) never prompts. It prints one JSON object on stdout and notes on stderr. A missing Lightning Address is exit 2 and names --lightning-address.

satsgate init --json --lightning-address merchant@pay.example
satsgate init --json --lightning-address merchant@pay.example --want-usdc
satsgate init --docker --framework fastapi

JSON (schema_version 1) includes ok, status, exit_code, api_url, kind, account (client_id, key_preview, fingerprint, reused), payee_lightning_address, usdc, files, route, test_402, lud21, address_options, start_command, next_steps, warnings, and error. A key is shown as sg_… or sgr_… plus the last four characters, and as a fingerprint. The connect link is not a JSON field.

LUD-21 check

After the test 402, init asks the core once for the status of that unpaid test invoice. It is a read: nothing is paid, nothing is debited, and no second invoice is created. The answer shows whether the Lightning Address advertises LUD-21 verify.

  • lud21.supported: true: a person can pay the QR from any Lightning wallet, and the proxy confirms the payment without a preimage.
  • lud21.supported: false and the warning lud21_not_supported: agents can still pay, because they send the preimage. A person who pays the QR from a wallet that does not show the preimage cannot finish. To accept those payments, use a Lightning Address that advertises LUD-21 verify.
  • lud21.supported: null and the warning lud21_not_checked: the check did not get an answer. Run satsgate init again to check.

The check never fails init and does not change the exit code. lud21 is null when init stopped before the check, for example when the test 402 failed. Human mode prints the same sentence after the Lightning Address.

"lud21": {
  "supported": false,
  "detail": "The Lightning Address does not advertise LUD-21 verify. Agents can still pay: they send the preimage. A person who pays the QR from a wallet that does not show the preimage cannot finish. To accept those payments, use a Lightning Address that advertises LUD-21 verify."
},
"warnings": ["lud21_not_supported"]

Exit codes: 0 done, 1 the API or the network failed, 2 usage, 3 a human has to decide, 4 rate-limited. A 429 includes retry_after_seconds and is not retried.

Files

Path Mode Contents
.satsgate/ 0700 directory
.satsgate/account.env 0600 SATSGATE_ACCOUNT_KEY
.satsgate/.gitignore *
.env 0600 when created here SATSGATE_API_KEY, SATSGATE_ORIGIN_SECRET
satsgate-proxy.yaml proxy config, no secrets
.satsgate/connect-link.txt 0600 wallet link in agent mode
.satsgate/last-check.json 0600 last LUD-21 result for status; a cache, not listed in files
.satsgate/try.json 0600 the pending try for --check, with its macaroon and, after the unlock, the saved origin response

A second run reuses the account and the keys. An existing YAML or snippet is not overwritten (agent exit 3 file_exists). A different SATSGATE_* value is exit 3 env_conflict. A symlink is refused. On Windows the run finishes and warns permissions_not_restricted; WSL is the supported way to get owner-only files.

USDC payments: Base network only

USDC payments use Base only. Ethereum mainnet, Polygon, Solana, Arbitrum, and any other chain are not accepted.

Network Network id Circle USDC contract Status
Base Sepolia (testnet) eip155:84532 0x036CbD53842c5426634e7929541eC2318f3dCF7e Testing. It is not a network for real buyers.
Base eip155:8453 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 Live mode (on by default on api.satsgate.org; a self-hosted core needs SATSGATE_X402_CDP=1 and CDP credentials, see self-hosting).

payTo must be an address you control on Base. The USDC moves from the buyer to that address. Satsgate does not hold a buyer wallet and does not run its own facilitator.

When USDC is off, the next steps of a successful init include: "To also accept USDC on Base, run satsgate init again with --want-usdc." --want-usdc mints a one-time connect link when the EVM payee is not verified yet. A terminal prints the link once and can open it. Otherwise it is written to .satsgate/connect-link.txt and is not printed. After the payee is verified, a later run sets x402: true and x402_mode: test. The unpaid 402 then includes a Base Sepolia offer. Paying that offer is a later step for a buyer agent (satsgate-mcp-pay), with the key on the buyer's machine. Test mode is free.

To turn USDC test mode off, delete the YAML and run init again. It is regenerated and the keys are reused. Manual edits to the YAML are lost. To keep them, remove the route's x402 and x402_mode lines and restart the proxy instead.

Lightning has no test network. A paid Lightning request moves real sats to the merchant's own address.

Start

uvx --env-file .env satsgate-proxy --config satsgate-proxy.yaml

satsgate 0.3.0. --docker writes docker-compose.satsgate.yml and prints docker compose -f docker-compose.satsgate.yml up. The compose file uses the public image ghcr.io/mike-io-hash/satsgate-proxy:0.16.0. The generated service listens on 0.0.0.0; the YAML written for uvx stays on 127.0.0.1.

Inside a Python app

A FastAPI or Starlette app can skip the proxy: put @paid(sats=10) under the route decorator of each priced route, and add app = protect(app). Both come from satsgate. protect reads SATSGATE_API_KEY from the environment. See Charge from inside a Python app.

Contributors' note

To build the image yourself, use proxy/Dockerfile from the repo. From a checkout: pip install -e sdk/python -e proxy -e cli.

--framework fastapi, express, or nginx copies the existing origin check. A client that can reach the origin directly must fail closed. The Caddy file in the package is a note, not an HMAC check.

Metadata

Release files for satsgate 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for satsgate 0.3.0
File Size Uploaded Provenance Actions
satsgate-0.3.0.tar.gz 50.2 kB With provenance Details for satsgate-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for satsgate 0.3.0
File Interpreter ABI Platform Actions
satsgate-0.3.0-py3-none-any.whl Python 3 none any Details for satsgate-0.3.0-py3-none-any.whl

Total release size: 101.4 kB

Release files / satsgate-0.3.0.tar.gz

Download URL satsgate-0.3.0.tar.gz
Size 50.2 kB
Tags Source
SHA-256 checksum
How to use checksums
25c7f53cd7cbf26dc0ce0ac0245fe11d8c83c4abc0b714d576e943183c618889
BLAKE2b-256 checksum
How to use checksums
f7afb8361131c73eb1281894a1fc60b1c195373b92c733970d70d2aaf8412c3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / satsgate-0.3.0-py3-none-any.whl

Download URL satsgate-0.3.0-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d26ffddb4ccaa8454c9d2ff2054c00b7ed150bcadd2d4949fef1c81799d5728
BLAKE2b-256 checksum
How to use checksums
e74a6059759298970c9f20e7eb361239f6ad8b7d60179c451781142cfd185e23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for satsgate 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for satsgate-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page