How Lighter differs from a typical EVM integration
Unlike most exchanges, Lighter separates authority into two layers, and it’s important to understand which key does what before you start:- L1 account owner (the Privy wallet). A standard Ethereum address. This wallet owns the Lighter account and signs every on-chain action: registering a trading API key (
changePubKey), deposits, and withdrawals. All L1 interactions can be sponsored with native gas sponsorship. - L2 trading API key (a Lighter keypair). Use Lighter API keys to sign and submit orders directly to the order book. Lighter signs orders with a separate API key using its own signature scheme. This key is generated by the Lighter SDK and managed by your application.
A Privy embedded or server wallet cannot produce Lighter’s L2 order signatures — that scheme is
not ECDSA. Use the Privy embedded wallet to authorize the trading API key on-chain. Your
application holds the Lighter API key that signs orders, and Privy never has to expose a raw
private key to do so.
- Create a Lighter account
- Add funds to the Lighter account
- Register a Lighter trading API key
- Sign and submit trades to the Lighter order book
Prerequisites
Before you begin, make sure you have:- A Privy app with gas sponsorship enabled. Lighter’s contract is on Ethereum mainnet, so sponsor there (or fund the wallet with ETH for gas).
- Python 3.10+.
- The Lighter contract address on Ethereum mainnet:
0x3B4D794a66304F130a4Db8F2551B0070dfCf5ca7.
Installation
1. Create the account owner wallet
Create the Ethereum wallet that will own the Lighter account.2. Fund the account
To activate a Lighter account, deposit USDC directly into the Privy wallet. The minimum direct deposit is 1 USDC. USDC on Ethereum mainnet is0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48.
A deposit is two ordinary transactions signed by the Privy wallet: an ERC-20 approve to the Lighter contract, then deposit(to, assetIndex, routeType, amount) with routeType = 0 for the perps account.
Ethereum mainnet gas can be significant. For cheaper funding from Arbitrum, Base, and other
chains, Lighter also supports deposits through the Fun.xyz Universal Deposit Address — see the
deposits guide. API-key
registration in the next step is always a one-time mainnet transaction.
3. Register a trading API key
Generate a Lighter API keypair with the SDK, then register its public key on-chain withchangePubKey, signed by the Privy wallet. The signature scheme means the key is registered through the contract directly rather than handing a raw private key to the SDK — the recommended path when the account owner is a smart-contract or multi-sig wallet.
First, find the account index (assigned when the account was funded) and generate the keypair:
changePubKey(accountIndex, apiKeyIndex, pubKey) must be sent by the L1 address that owns the account (the Privy wallet). API key indices 2–254 are available (0–1 are reserved).
4. Place an order
With the API key registered, sign and submit orders using the LighterSignerClient. This uses the API key, not the Privy wallet.
base_amount and price are integers scaled by each market’s size and price decimals. Fetch
market metadata (decimals, indices) from Lighter’s orderBookDetails endpoint before placing
orders. See the trading guide for order types and
time-in-force options.Withdrawing
Withdrawals return funds to the account owner and are authorized by the Privy L1 wallet, either through the contract’swithdraw function or Lighter’s fast-withdraw flow (min 4 USDC). See the withdrawals guide.
Resources
Lighter API Docs
Lighter’s partner integration, trading, and deposit documentation.
Lighter Python SDK
The signer client, API-key generation, and order examples.
EVM Transactions with Privy
Learn how to send EVM transactions using Privy wallets.
Why use Privy with Lighter?
- Security: The account owner’s private key never leaves Privy’s secure infrastructure.
- Multi-sig ready: On-chain registration via
changePubKeyworks for smart-contract and multi-sig owners, no raw key required. - Simplicity: No key storage or rotation to manage for the account owner.
- Gas sponsorship: Sponsor account setup, deposits, and withdrawals so users never hold ETH.
You’re ready to build trading applications on Lighter with Privy.

