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
|`naga-dev`|`https://naga-dev-auth-service.getlit.dev`|`https://login.litgateway.com`| Use Lit's hosted endpoints while you prototype. Configure your SDK or environment variables with the URLs in this table. |
26
26
|`naga-test`|`https://naga-test-auth-service.getlit.dev`|`https://login.litgateway.com`| Start with the hosted endpoints for staging, then switch to your own infrastructure as you scale. |
27
-
|`naga`|`Run your own (recommended)`|`Run your own (recommended)`| Lit does not operate public Auth Service or Login Server endpoints for `naga`|
27
+
|`naga`|`Run your own (recommended)`|`Run your own (recommended)`| Lit does not (yet) operate public Auth Service or Login Server endpoints for `naga`|
28
28
29
29
<Note>
30
30
The hosted services are best suited for prototyping. Self-host the Auth
31
31
Service and Login Server for production traffic or when you need custom
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.
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>
7
-
❗️ Currently free on the dev network, so no need to deposit funds. More
8
-
details coming soon for test and production networks.
7
+
❗️ Payment status by network:
8
+
-**naga-dev** – usage is currently free; no deposits required.
9
+
-**naga-test** – payments are enabled using test tokens (see faucet link
10
+
below).
11
+
-**Mainnet** – coming soon; mainnet payment details will be announced
12
+
shortly.
9
13
</Warning>
10
14
11
15
<Note>
@@ -23,10 +27,11 @@ description: "Configure payment system for the Lit JS SDK"
23
27
24
28
The Payment Manager demonstrates Lit Protocol's payment system - a billing system for decentralised cryptographic services. Users pay for compute resources on the Lit network to access core services like:
25
29
26
-
- Encryption/Decryption - Secure data with programmable access control
27
-
- PKP Signing - Cryptographic keys that can sign transactions based on conditions
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).
30
+
-[Encryption/Decryption](/sdk/auth-context-consumption/encrypt-and-decrypt) - Secure data with programmable access control.
31
+
-[PKP Signing](/sdk/auth-context-consumption/pkp-sign) - Cryptographic keys that can sign transactions based on conditions.
32
+
-[Lit Actions](/sdk/auth-context-consumption/execute-js) - Serverless functions with cryptographic capabilities.
33
+
34
+
Similar to how you pay AWS for cloud computing, this system ensures the decentralised network can sustain itself and pay node operators. Each payer keeps a balance in the on-chain Lit Ledger contract funded with `$LITKEY` (or `$tstLPX` on testnet), which the network debits as requests execute. 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).
Define spending limits for the users you want to sponsor (values are in wei).
112
+
113
+
<CodeGroup>
114
+
115
+
```typescript
116
+
awaitpaymentManager.setRestriction({
117
+
totalMaxPrice: '1000000000000000000', // 1 ETH equivalent limit
118
+
requestsPerPeriod: '100', // max number of sponsored requests in a period
119
+
periodSeconds: '3600', // rolling window (1 hour in this example)
120
+
});
121
+
```
122
+
123
+
</CodeGroup>
124
+
125
+
</Step>
101
126
102
-
Leverage the hosted Auth Service to manage delegation without exposing private keys in your application:
127
+
<Steptitle="Delegate users">
103
128
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.
129
+
With restrictions set, delegate one or more users to spend from your payer wallet.
106
130
107
-
> The legacy capacity-credit minting flow has been removed. Payment delegation now interacts directly with the Payment Manager contracts.
131
+
<CodeGroup>
132
+
133
+
```typescript
134
+
awaitpaymentManager.delegatePaymentsBatch({
135
+
userAddresses: ['0xAlice...', '0xBob...'],
136
+
});
137
+
```
138
+
139
+
</CodeGroup>
140
+
141
+
</Step>
142
+
143
+
<Steptitle="Remove users (optional)">
144
+
145
+
Undelegate users when you no longer want to sponsor them.
146
+
147
+
<CodeGroup>
148
+
149
+
```typescript
150
+
awaitpaymentManager.undelegatePaymentsBatch({
151
+
userAddresses: ['0xAlice...'],
152
+
});
153
+
```
154
+
155
+
</CodeGroup>
156
+
157
+
</Step>
158
+
</Steps>
159
+
160
+
## **Alternatively**
161
+
162
+
Manage delegation via the hosted or self-hosted Auth Service (see [Auth Services setup](/sdk/getting-started/auth-services) for the full flow).
163
+
164
+
## After Payment Delegation
165
+
166
+
**Users decrypt as normal** – we still call `litClient.decrypt` with an auth context; the network draws fees from the delegated payer instead of the user’s wallet.
167
+
168
+
<Note>
169
+
ℹ️ `userMaxPrice` is recommended for sponsored sessions, typically the same value or less than the the restriction the sponsor set; optional guardrail when self-funded.
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:
197
+
198
+
- Call `authService.registerPayer` (hosted or self-hosted) to derive a payer wallet + `payerSecretKey`.
199
+
- Call `authService.delegateUsers` (`/add-users`) to sponsor a list of user addresses.
200
+
- Or skip the service entirely and use the Payment Manager methods directly (example below).
- 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