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:
Encryption/Decryption - Secure data with programmable access control
PKP Signing - Cryptographic keys that can sign transactions based on conditions
Lit Actions - Serverless functions with cryptographic capabilities
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).
1
Payment Manager Setup
Copy
import { createLitClient } from '@lit-protocol/lit-client';import { nagaDev } from '@lit-protocol/networks';// 1. Create lit clientconst litClient = await createLitClient({ network: nagaDev });// 2. Get PaymentManager instance (requires account for transactions)const paymentManager = await litClient.getPaymentManager({ account: yourAccount // viem account instance});
2
Create an account
Copy
// 1. import the useWalletClient function from wagmiimport { useWalletClient } from 'wagmi';// 2. Use your connected wallet as the accountconst { data: myAccount } = useWalletClient();
3
Deposit funds
Copy
// 1. Deposit funds to your own account const result = await paymentManager.deposit({ amountInEth: "0.1" }); console.log(`Deposit successful: ${result.hash}`); // Returns: { hash: string, receipt: object }