Lighter Protocol
Trade on Lighter - a zero-knowledge rollup orderbook DEX with millisecond latency and zero fees.
Quick Start (Read-Only)
CODEBLOCK0
What is Lighter?
- - Zero fees for retail traders
- Millisecond latency
- ZK proofs of all operations
- Backed by Founders Fund, Robinhood, Coinbase Ventures
API Endpoint: https://mainnet.zklighter.elliot.ai
Chain ID: 300
⚠️ Security Considerations
Third-Party Dependencies
This skill can work with just requests library for read-only operations. For signing orders, you have two options:
Option A: Minimal (Read-Only)
pip install requests
Only for public data (markets, order books, prices).
Option B: Full Trading
Requires the official Lighter SDK. Review and verify before installing:
- - SDK Repository: https://github.com/elliottech/lighter-python
- Verify the repository owner, stars, and code before running any setup
External Code
Only proceed with external SDK if you:
- 1. Have reviewed the GitHub repository
- Understand what the code does
- Use a dedicated burner wallet, not your main wallet
Environment Variables
| Variable | Required | Description | Where to Find |
|---|
| INLINECODE0 | For orders | API key from Lighter SDK setup | See "Getting an API Key" section below |
| INLINECODE1 |
For orders | Your Lighter subaccount index (0-252) | See "Getting Your Account Index" section below |
|
LIGHTER_L1_ADDRESS | Optional | Your ETH address (0x...) used on Lighter | Your MetaMask/Wallet address |
Setting Up Your Credentials
Step 1: Get your L1 Address
- - This is your Ethereum address (e.g.,
0x1234...abcd) - Use the same wallet you connect to Lighter dashboard
Step 2: Get your Account Index
curl "https://mainnet.zklighter.elliot.ai/api/v1/accountsByL1Address?l1_address=YOUR_ETH_ADDRESS"
Response returns
sub_accounts[].index — that's your account index (typically 0 for main account).
Step 3: Get your API Key
- 1. Install Lighter Python SDK: INLINECODE5
- Follow the setup guide: https://github.com/elliottech/lighter-python/blob/main/examples/system_setup.py
- The SDK generates API keys tied to your account
- Store the private key securely — never commit to git
Quick test (read-only, no credentials):
CODEBLOCK3
API Usage
Public Endpoints (No Auth)
CODEBLOCK4
Authenticated Endpoints
CODEBLOCK5
Getting Your Account Index
See "Setting Up Your Credentials" table above for the quick curl command.
Getting an API Key
See "Setting Up Your Credentials" table above for the step-by-step guide.
Common Issues
"Restricted jurisdiction":
- - Lighter has geographic restrictions - ensure compliance with their terms
SDK signing issues:
- - Use createmarketorder() instead of create_order() for more reliable execution
Market IDs
BTC-USD |
| 3 | SOL-USD |
Links
- - API: https://mainnet.zklighter.elliot.ai
- Dashboard: https://dashboard.zklighter.io
- SDK: https://github.com/elliottech/lighter-python
Additional Examples
See USAGE.md in this skill folder for:
- - Detailed curl commands for all endpoints
- Order book and trade queries
- Account and position checks
- Signed transaction flow (nonce → sign → broadcast)
Disclaimer: Review all external code before running. Use dedicated wallets for trading.
Lighter 协议
在 Lighter 上交易——一个具有毫秒级延迟和零费用的零知识汇总订单簿 DEX。
快速开始(只读)
bash
市场是公开的——无需凭证
curl https://mainnet.zklighter.elliot.ai/api/v1/orderBooks
什么是 Lighter?
- - 零售交易者零费用
- 毫秒级延迟
- 所有操作的零知识证明
- 由 Founders Fund、Robinhood、Coinbase Ventures 支持
API 端点: https://mainnet.zklighter.elliot.ai
链 ID: 300
⚠️ 安全注意事项
第三方依赖
此技能仅需 requests 库 即可进行只读操作。如需签名订单,您有两个选择:
选项 A:最小化(只读)
bash
pip install requests
仅用于公共数据(市场、订单簿、价格)。
选项 B:完整交易
需要官方 Lighter SDK。安装前请仔细审查和验证:
- - SDK 仓库:https://github.com/elliottech/lighter-python
- 在运行任何设置前,请验证仓库所有者、星标数和代码
外部代码
仅在以下情况下使用外部 SDK:
- 1. 您已审查过 GitHub 仓库
- 您了解代码的功能
- 使用专用的临时钱包,而非您的主钱包
环境变量
| 变量 | 必需 | 描述 | 查找位置 |
|---|
| LIGHTERAPIKEY | 订单必需 | 来自 Lighter SDK 设置的 API 密钥 | 见下方获取 API 密钥部分 |
| LIGHTERACCOUNTINDEX |
订单必需 | 您的 Lighter 子账户索引(0-252) | 见下方获取您的账户索引部分 |
| LIGHTER
L1ADDRESS | 可选 | 您在 Lighter 上使用的 ETH 地址(0x...) | 您的 MetaMask/钱包地址 |
设置您的凭证
步骤 1:获取您的 L1 地址
- - 这是您的以太坊地址(例如 0x1234...abcd)
- 使用您连接到 Lighter 仪表板的同一钱包
步骤 2:获取您的账户索引
bash
curl https://mainnet.zklighter.elliot.ai/api/v1/accountsByL1Address?l1_address=您的ETH地址
响应返回 sub_accounts[].index——这就是您的账户索引(主账户通常为 0)。
步骤 3:获取您的 API 密钥
- 1. 安装 Lighter Python SDK:pip install lighter-python
- 按照设置指南操作:https://github.com/elliottech/lighter-python/blob/main/examples/system_setup.py
- SDK 会生成与您账户绑定的 API 密钥
- 安全存储私钥——切勿提交到 git
快速测试(只读,无需凭证):
bash
curl https://mainnet.zklighter.elliot.ai/api/v1/orderBooks
API 使用
公共端点(无需认证)
bash
列出所有市场
curl https://mainnet.zklighter.elliot.ai/api/v1/orderBooks
获取订单簿
curl https://mainnet.zklighter.elliot.ai/api/v1/orderBook?market_id=1
获取近期交易
curl https://mainnet.zklighter.elliot.ai/api/v1/trades?market_id=1
需要认证的端点
bash
账户余额(需要在请求头中包含 API 密钥)
curl -H x-api-key: $LIGHTER
APIKEY \
https://mainnet.zklighter.elliot.ai/api/v1/account?by=index&value=$LIGHTER
ACCOUNTINDEX
获取您的账户索引
请参见上方设置您的凭证表格中的快速 curl 命令。
获取 API 密钥
请参见上方设置您的凭证表格中的分步指南。
常见问题
受限司法管辖区:
- - Lighter 有地理限制——请确保遵守其条款
SDK 签名问题:
- - 使用 createmarketorder() 替代 create_order() 以获得更可靠的执行
市场 ID
BTC-USD |
| 3 | SOL-USD |
链接
- - API:https://mainnet.zklighter.elliot.ai
- 仪表板:https://dashboard.zklighter.io
- SDK:https://github.com/elliottech/lighter-python
更多示例
请参阅此技能文件夹中的 USAGE.md 文件,了解:
- - 所有端点的详细 curl 命令
- 订单簿和交易查询
- 账户和持仓检查
- 签名交易流程(nonce → 签名 → 广播)
免责声明: 运行前请审查所有外部代码。请使用专用钱包进行交易。