Skip to content

Commit c6e6188

Browse files
committed
docs: update auth-services and payment-manager setup documentation for clarity and accuracy
1 parent 4ce8a5f commit c6e6188

File tree

2 files changed

+67
-40
lines changed

2 files changed

+67
-40
lines changed

docs/sdk/getting-started/auth-services.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Lit hosts default Auth Service instances so you can build without deploying infr
2424
| ----------- | ------------------------------------------- | ------------------------------ | ----- |
2525
| `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. |
2626
| `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` |
2828

2929
<Note>
3030
The hosted services are best suited for prototyping. Self-host the Auth

docs/sdk/getting-started/payment-manager-setup.mdx

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ description: 'Configure payment system for the Lit JS SDK'
44
---
55

66
<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.
913
</Warning>
1014

1115
<Note>
@@ -23,10 +27,11 @@ description: 'Configure payment system for the Lit JS SDK'
2327

2428
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:
2529

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).
3035

3136
<Steps>
3237
<Step title="Payment Manager Setup">
@@ -40,7 +45,7 @@ const litClient = await createLitClient({ network: nagaTest });
4045

4146
// 2. Get PaymentManager instance (requires account for transactions)
4247
const paymentManager = await litClient.getPaymentManager({
43-
account: yourAccount // viem account instance
48+
account: yourAccount // viem account instance
4449
});
4550

4651
````
@@ -98,49 +103,73 @@ console.log(`Deposit successful: ${result.hash}`);
98103

99104
</Steps>
100105

101-
## Sponsoring Your Users (Capacity Delegation Replacement)
106+
## Sponsoring Your Users
102107

103-
If your app previously minted Capacity Credits and handed users a `CapacityDelegationAuthSig`, the equivalent Naga flow is:
108+
<Steps>
109+
<Step title="Define spending limit">
104110

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` (for a single user) or `paymentManager.delegatePaymentsBatch` (for multiple users) with your server-side account; this writes to the same Payment Delegation contract.
111+
Define spending limits for the users you want to sponsor (values are in wei).
113112

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.
113+
<CodeGroup>
118114

119-
```typescript server
120-
// Manual delegation without Auth Service
121-
import { createLitClient } from '@lit-protocol/lit-client';
122-
import { privateKeyToAccount } from 'viem/accounts';
123-
import { nagaTest } from '@lit-protocol/networks';
115+
```typescript
116+
await paymentManager.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+
```
124122

125-
const payerAccount = privateKeyToAccount(
126-
process.env.PAYER_PRIVATE_KEY as `0x${string}`
127-
);
128-
const litClient = await createLitClient({ network: nagaTest });
123+
</CodeGroup>
129124

130-
const paymentManager = await litClient.getPaymentManager({
131-
account: payerAccount,
132-
});
125+
</Step>
126+
127+
<Step title="Delegate users">
133128

134-
// Delegate a single user
135-
await paymentManager.delegatePayments({ userAddress: '0xUser...' });
129+
With restrictions set, delegate one or more users to spend from your payer wallet.
136130

137-
// Or delegate multiple users in one transaction
131+
<CodeGroup>
132+
133+
```typescript
138134
await paymentManager.delegatePaymentsBatch({
139135
userAddresses: ['0xAlice...', '0xBob...'],
140136
});
141137
```
142138

139+
</CodeGroup>
140+
141+
</Step>
142+
143+
<Step title="Remove users (optional)">
144+
145+
Undelegate users when you no longer want to sponsor them.
146+
147+
<CodeGroup>
148+
143149
```typescript
150+
await paymentManager.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.
170+
</Note>
171+
172+
```typescript highlight={18}
144173
// Client-side decrypt with sponsored payments
145174
const authContext = await authManager.createEoaAuthContext({
146175
litClient,
@@ -158,7 +187,7 @@ const response = await litClient.decrypt({
158187
unifiedAccessControlConditions: accs,
159188
authContext,
160189
chain: 'ethereum',
161-
userMaxPrice: 1000000000000000000n, // required for sponsored sessions, typically the same value as the restriction the sponsor set; optional guardrail when self-funded
190+
userMaxPrice: 1000000000000000000n,
162191
});
163192
```
164193

@@ -170,8 +199,6 @@ Leverage the hosted Auth Service to manage delegation without exposing private k
170199
- Call `authService.delegateUsers` (`/add-users`) to sponsor a list of user addresses.
171200
- Or skip the service entirely and use the Payment Manager methods directly (example below).
172201

173-
> The legacy (V7, Datil) capacity-credit minting flow has been removed. Payment delegation now interacts directly with the Payment Manager contracts.
174-
175202
```typescript
176203
import { createLitClient } from '@lit-protocol/lit-client';
177204
import { nagaTest } from '@lit-protocol/networks';

0 commit comments

Comments
 (0)