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 trypays 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 initwrites the config for your API or your remote MCP server.satsgate statusreads 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 --price deep_search=21 --price ping=free
--kind mcp writes one route with methods: [POST, DELETE] on --mcp-path (default /mcp) and signal: in_band. Every tool costs 10 sats (default: {price_sats: 10, access: per_request}) unless the table says otherwise; initialize, tools/list, and other MCP messages are forwarded free. Before the table, init calls initialize and tools/list on the upstream (default http://127.0.0.1:8000) and lists each tool; it never calls a tool. --price NAME=SATS or --price NAME=free sets one tool, and --price '*=15' changes the default. --paid-tool NAME=SATS is the same as --price NAME=SATS. Changed in 0.5.0: tools not named are charged 10 sats too; a config from 0.4 (default free) is kept on a re-run. 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>.
Price table
Without --path, init writes a price table:
- Every path costs 10 sats (
/**, methods GET, POST, PUT, PATCH, DELETE,access: per_request). /health,/docs,/openapi.json,/robots.txt, and/favicon.icoare infree_paths. Free paths are checked first, so a free path always wins.- The routes your API publishes are listed too.
initreads, in order,/openapi.json,/swagger.json,/v3/api-docs,/docs/openapi.json,/api/openapi.json, and/swagger/v1/swagger.jsonon the upstream (defaulthttp://127.0.0.1:3000), with a 3-second timeout per request and 8 seconds in all. It only reads; your code does not change./items/{id}becomes/items/*, and the document it found is made free. Up to 500 routes are listed. - Without a published list, the table starts with
/**only and the warningcatalog_not_detected. Add routes by hand, or start your API and runinitagain.
Human mode shows the table once. Type /weather 15 to set a price, /stats free to make a route free, /old remove to drop a row, u to turn USDC on or off, and Enter on an empty line to confirm. /weather/** 20 prices everything under /weather that has no price of its own. Above 30 routes, the table groups them by first segment (/weather/** 12 routes 10 sats); type a group number to open it, or all. /** cannot be free: free paths always win, so nothing would be charged.
Agents pass the same changes as flags: --price /weather=15, --price /stats=free, repeatable. A bad value stops before any account is opened (exit 2 bad_price) and the message says how to write it. The JSON lists every row in catalog (target, kind, price_sats, free, source, usdc, path) and what was read in detection (source openapi, tools_list, kept, or none, with url, count, and detail).
The YAML carries an # init-checksum: line. Edit the file freely: after an edit, init keeps it as it is and still does the account, the Lightning Address, .env, and the terms (config: kept_edited, warning config_kept_edited, no test 402). Only a run that needs the YAML changed (--price, --usdc, --upstream, --public-url, --path, --redetect, --mcp-path) stops with exit 3 file_exists, changes nothing, and lists the lines to paste or the command to move the file aside. A file that is not a proxy config is never used (exit 3 file_exists). A re-run on an unedited table keeps it and only changes USDC (config: kept); a person sees the table once and keeps it with Enter. A kept table with no listed routes is read again from the upstream, and --redetect reads it again on purpose (config: redetected). A re-read keeps USDC, the default price, the paths you made free, and the price of every route still published. A config written by satsgate 0.2 to 0.4 is kept as it is (config: kept_legacy), and --path PATH still writes that single-route config (one GET route at 10 sats).
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, terms not accepted, USDC on a route without a verified EVM payee, or a rejected key).
Terms
On a server that asks for terms acceptance, init, try, and status take --accept-terms. A person running satsgate init or satsgate try is asked once, after the account is ready and before the test 402 or the invoice, with the vendor declaration and a link to the terms. An agent is never asked, and nothing is recorded without --accept-terms. JSON output adds terms: version, accepted, can_charge, grace_until, and next_step (null on a server that does not ask).
When the account cannot charge yet, init and try keep the setup, skip the test 402 or the invoice, and end with exit 0, status: "terms_required", and the next step. status lists terms_not_accepted under warnings and exits 3. Both add the item to action_required with the exact command. An existing account inside the grace period keeps working and sees the date. satsgate status --accept-terms accepts for the account in this folder. In a terminal, status ends with Status: OK. or Status: needs attention (...).
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), the Lightning Address, whether to also accept USDC when no wallet is connected yet, and shows the price table. Each step prints one line that says what happens and why. The proxy signature check is a flag (--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 --usdc=test
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 (enabled, connect_link_file, expires_at, and since 0.5.0 status on, off, or pending, mode, wallet_verified), files, route, config, catalog, detection, test_402, lud21, address_options, start_command, next_steps, action_required, warnings, and error. Since 0.5.3, usdc adds expires_at_iso (the same time as expires_at, in UTC), and action_required lists what only the owner can finish, each as {reason, detail, command}: terms_not_accepted, usdc_pending, env_not_gitignored, env_is_group_readable. Exit codes do not change for them. A failed run keeps catalog and detection, and its next_steps repeat the fix. 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: falseand the warninglud21_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.initandstatusboth exit 0 for it.lud21.supported: nulland the warninglud21_not_checked: the check did not get an answer. Runsatsgate initagain 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 (both modes; a person also sees it once on screen) |
.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 saved in .satsgate/ without asking (--new-account opens another) and keeps the saved Lightning Address: a person presses Enter, an agent leaves out --lightning-address. A YAML init did not write is not overwritten (see above), nor is a foreign snippet (exit 3 file_exists). A different SATSGATE_* value is exit 3 env_conflict, and the message names the fix: --replace-api-key for a SATSGATE_API_KEY the API refuses (checked before any account is opened), or removing the line. When the test 402 fails because the Lightning Address provider did not answer or refused, the message says so and gives satsgate init --lightning-address NEW --replace-lightning-address. The address is trimmed, a lightning: prefix is dropped, and spaces or a second @ are refused. 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.
USDC from init: when the EVM wallet is already verified, a new table has USDC on in live mode (x402: true, x402_mode: live) and the review screen shows it as one line that u turns off. If this API does not take real USDC yet and no flag asked for it, init goes on with Lightning only and warns usdc_live_unavailable. Without a verified wallet, human mode asks once ("Also accept USDC on Base? You need to connect a wallet (about 2 minutes)"). Yes prints the one-time connect link, waits while you connect (up to 10 minutes, checking every 3 seconds), and turns USDC on by itself; Enter goes on without it.
Agents: --usdc (live), --usdc=test (Base Sepolia), --usdc=off. Without a verified wallet, --usdc writes the link to .satsgate/connect-link.txt (0600, never printed), leaves USDC off, sets usdc.status to pending (the top-level status stays ready), and adds the exact command to run after connecting. A person gets the same file too, with its expiry, and the rerun command without --json. --want-usdc still works as --usdc=test and warns want_usdc_renamed. Paying a test offer is a step for a buyer agent (satsgate-mcp-pay), with the key on the buyer's machine. Test mode is free.
A re-run does not turn USDC off by itself. On a table init wrote, --usdc=off turns it off. On a 0.4 config, delete the YAML and run init again with --usdc=off. 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.5.3. --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.17.2. The generated service listens on 0.0.0.0; the YAML written for uvx stays on 127.0.0.1. Inside the container, an upstream on 127.0.0.1 or localhost is rewritten to host.docker.internal (with extra_hosts: host.docker.internal:host-gateway for Linux), so the app on the host must listen on an address Docker can reach, such as 0.0.0.0. Other hosts are left as they are. With --docker, start_command and the first next step are the docker compose command.
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). An MCP tool (MCPServer in mcp 2.x, FastMCP in mcp 1.x) uses @paid_tool(sats=10) and protect(mcp.streamable_http_app()). Both come from satsgate. protect reads SATSGATE_API_KEY from the environment: start the app with .env loaded, for example uvicorn app:app --env-file .env. 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 proxy signature check (an HMAC check of X-Satsgate-Signature). A client that can reach your server directly must fail closed. The Caddy file in the package is a note, not an HMAC check. It is not the origin check of the hosted gate (POST /v1/sites/{slug}/verify-origin), which proves you control a site.
Metadata
Release files for satsgate 0.5.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| satsgate-0.5.3.tar.gz | 80.2 kB | With provenance | Details for satsgate-0.5.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| satsgate-0.5.3-py3-none-any.whl | Python 3 | none | any | Details for satsgate-0.5.3-py3-none-any.whl |
Total release size: 159.8 kB
Release files / satsgate-0.5.3.tar.gz
| Download URL | satsgate-0.5.3.tar.gz |
|---|---|
| Size | 80.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c467283a6bfeffe2e71d8bc8ac75ced45958d676e6fc933d259c44c20319f421
|
|
BLAKE2b-256 checksum How to use checksums |
9da3bab3887c79403ab73dc848254b4d87b4f9e4d32582b9e2d1d65bd6232d0a
|
| 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 Dec 5, 2026.
Transparency logRelease files / satsgate-0.5.3-py3-none-any.whl
| Download URL | satsgate-0.5.3-py3-none-any.whl |
|---|---|
| Size | 79.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bca82ebdf47e952b93dcabb20389be0e124aea3ee3130c1b4fd844a74adfb480
|
|
BLAKE2b-256 checksum How to use checksums |
c40287957339e59b4653006d000305f2a167d4ce2f9283860dc84629185badf8
|
| 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 Dec 5, 2026.
Transparency logSecurity for satsgate 0.5.3
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.
Attestation for satsgate-0.5.3.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 Dec 5, 2026.
Transparency logA 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.