Skip to content

Commit d5688d1

Browse files
committed
Add change account tier example script.
1 parent 05eeaaa commit d5688d1

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

examples/change_account_tier.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import asyncio
2+
import logging
3+
import lighter
4+
import requests
5+
6+
logging.basicConfig(level=logging.DEBUG)
7+
8+
BASE_URL = "https://mainnet.zklighter.elliot.ai"
9+
10+
# You can get the values from the system_setup.py script
11+
# API_KEY_PRIVATE_KEY =
12+
# ACCOUNT_INDEX =
13+
# API_KEY_INDEX =
14+
15+
16+
async def main():
17+
client = lighter.SignerClient(
18+
url=BASE_URL,
19+
private_key=API_KEY_PRIVATE_KEY,
20+
account_index=ACCOUNT_INDEX,
21+
api_key_index=API_KEY_INDEX,
22+
)
23+
24+
err = client.check_client()
25+
if err is not None:
26+
print(f"CheckClient error: {err}")
27+
return
28+
29+
auth, err = client.create_auth_token_with_expiry(
30+
lighter.SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY
31+
)
32+
33+
response = requests.post(
34+
f"{BASE_URL}/api/v1/changeAccountTier",
35+
data={"account_index": ACCOUNT_INDEX, "new_tier": "premium"},
36+
headers={"Authorization": auth},
37+
)
38+
if response.status_code != 200:
39+
print(f"Error: {response.text}")
40+
return
41+
print(response.json())
42+
43+
44+
if __name__ == "__main__":
45+
asyncio.run(main())

0 commit comments

Comments
 (0)