You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sdk/getting-started/auth-services.mdx
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,25 @@ Lit hosts default Auth Service instances so you can build without deploying infr
32
32
configuration.
33
33
</Note>
34
34
35
+
## Payment Delegation APIs
36
+
37
+
The Auth Service also exposes lightweight endpoints that sponsor user requests on the network. These are the same APIs the Lit SDK calls when you use `litClient.authService.registerPayer` / `delegateUsers` from the Payment Manager guide.
38
+
39
+
-`POST /register-payer`
40
+
- Headers: `x-api-key`.
41
+
- Behaviour: generates a random `payerSecretKey`, hashes it with the API key, and derives a child wallet from `LIT_DELEGATION_ROOT_MNEMONIC`.
42
+
- Response: `{ success, payerWalletAddress, payerSecretKey }`. The service **does not** persist the secret—you must store it securely (KMS, vault, etc.).
43
+
- Rotation: call the endpoint again with the same API key to rotate the secret and derive a new child wallet.
44
+
-`POST /add-users`
45
+
- Headers: `x-api-key`, `payer-secret-key`; body is a JSON array of user addresses.
46
+
- Behaviour: recomputes the same child wallet on the fly and calls `PaymentManager.delegatePaymentsBatch` so the payer sponsors those users.
47
+
48
+
<Tip>
49
+
Running the Auth Service yourself keeps the derivation mnemonic and payer secrets inside your infrastructure. The Lit-hosted instance is great for quick starts, but you remain responsible for storing the returned `payerSecretKey`.
50
+
</Tip>
51
+
52
+
If you prefer not to run an Auth Service at all, you can still sponsor users manually: create a payer wallet, fund it, and call `paymentManager.delegatePayments*` directly from your backend. See [Payment Manager Setup](/sdk/getting-started/payment-manager-setup#sponsoring-your-users-capacity-delegation-replacement) for sample code.
Copy file name to clipboardExpand all lines: docs/sdk/getting-started/payment-manager-setup.mdx
+91-25Lines changed: 91 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: "Payment Manager Setup"
3
-
description: "Configure payment system for the Lit JS SDK"
2
+
title: 'Payment Manager Setup'
3
+
description: 'Configure payment system for the Lit JS SDK'
4
4
---
5
5
6
6
<Warning>
@@ -26,7 +26,7 @@ The Payment Manager demonstrates Lit Protocol's payment system - a billing syste
26
26
- Encryption/Decryption - Secure data with programmable access control
27
27
- PKP Signing - Cryptographic keys that can sign transactions based on conditions
28
28
- Lit Actions - Serverless functions with cryptographic capabilities
29
-
Similar to how you pay AWS for cloud computing, this\system ensures the decentralised network can sustain itself and pay node operators. You can deposit funds, request withdrawals with security delays, and manage balances for yourself or other users (enabling applications to sponsor their users' costs for better UX).
29
+
Similar to how you pay AWS for cloud computing, this\system ensures the decentralised network can sustain itself and pay node operators. You can deposit funds, request withdrawals with security delays, and manage balances for yourself or other users (enabling applications to sponsor their users' costs for better UX).
## Sponsoring Your Users (Capacity Delegation Replacement)
102
+
103
+
If your app previously minted Capacity Credits and handed users a `CapacityDelegationAuthSig`, the equivalent Naga flow is:
104
+
105
+
1.**Fund a payer wallet** – call `litClient.getPaymentManager({ account })` and deposit $LITKEY ($tstLPX in testnet) into the ledger contract (see examples above).
106
+
2.**Register the payer** – decide how you want to provision and operate the sponsor wallet:
107
+
-**Lit-hosted Auth Service** – call `authService.registerPayer`; Lit derives the wallet + `payerSecretKey` for you (ideal for prototypes).
108
+
-**Self-hosted Auth Service** – deploy the open-source service (see [Auth Services setup](/sdk/getting-started/auth-services)) so derivation stays within your infrastructure. You’ll supply your own `LIT_DELEGATION_ROOT_MNEMONIC`.
109
+
-**Manual (no Auth Service)** – generate a wallet yourself (e.g. `privateKeyToAccount`) and store the private key securely; you’ll call the Payment Manager directly in the next step.
110
+
3.**Delegate end-user addresses** – map users to the payer:
111
+
- Using an Auth Service: POST to `authService.add-users`.
112
+
- Manual route: call `paymentManager.delegatePayments*` with your server-side account; this writes to the same Payment Delegation contract.
113
+
114
+
<Note>
115
+
For production environments we recommend running your own Auth Service (self-hosted) so you retain full custody over the `LIT_DELEGATION_ROOT_MNEMONIC` and derivation secrets. The Lit-hosted Auth Service is handy for prototypes and quick starts, but you still remain responsible for storing the returned `payerSecretKey` securely.
116
+
</Note>
117
+
4.**Users decrypt as normal** – the browser still calls `litClient.decrypt` with an auth context; the network draws fees from the delegated payer instead of the user’s wallet.
- Builds a pricing context during handshake (product, per-node prices, threshold).
168
+
- Encrypts requests per node using the JIT keyset.
169
+
- Emits per-node max price in the session signature.
170
+
- Lets the validators call `Ledger.chargeUser` against the delegated payer wallet.
171
+
100
172
## Auth Service API Endpoints
101
173
102
-
Leverage the hosted Auth Service to manage delegation without exposing private keys in your application:
174
+
Leverage the hosted Auth Service to manage delegation without exposing private keys in your application. Full request/response details live in the [Auth Services setup guide](/sdk/getting-started/auth-services#payment-delegation-apis). In practice you will:
103
175
104
-
-`POST /register-payer` - Send your `x-api-key` header to receive a delegated payer address and `payerSecretKey`. Persist this secret securely; it is required for all future delegation calls.
105
-
-`POST /add-users` - Provide headers `x-api-key` and `payer-secret-key` plus a JSON body containing an array of user addresses. The Auth Service uses the Payment Manager internally to delegate payments to each address in a single transaction.
176
+
- Call `authService.registerPayer` (hosted or self-hosted) to derive a payer wallet + `payerSecretKey`.
177
+
- Call `authService.delegateUsers` (`/add-users`) to sponsor a list of user addresses.
178
+
- Or skip the service entirely and use the Payment Manager methods directly (example below).
106
179
107
180
> The legacy capacity-credit minting flow has been removed. Payment delegation now interacts directly with the Payment Manager contracts.
- For hosted or self-hosted deployments, see the derivation and rotation notes in the [Auth Services guide](/sdk/getting-started/auth-services#payment-delegation-apis). Manual deployments can always provision and delegate entirely via the `PaymentManager` helper without touching these endpoints.
0 commit comments