From d5688d173808890d840573ce3343a52a2e1cdbe3 Mon Sep 17 00:00:00 2001 From: Hasan Bal Date: Thu, 26 Jun 2025 17:23:44 -0400 Subject: [PATCH] Add change account tier example script. --- examples/change_account_tier.py | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 examples/change_account_tier.py diff --git a/examples/change_account_tier.py b/examples/change_account_tier.py new file mode 100644 index 0000000..c5aec44 --- /dev/null +++ b/examples/change_account_tier.py @@ -0,0 +1,45 @@ +import asyncio +import logging +import lighter +import requests + +logging.basicConfig(level=logging.DEBUG) + +BASE_URL = "https://mainnet.zklighter.elliot.ai" + +# You can get the values from the system_setup.py script +# API_KEY_PRIVATE_KEY = +# ACCOUNT_INDEX = +# API_KEY_INDEX = + + +async def main(): + client = lighter.SignerClient( + url=BASE_URL, + private_key=API_KEY_PRIVATE_KEY, + account_index=ACCOUNT_INDEX, + api_key_index=API_KEY_INDEX, + ) + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + auth, err = client.create_auth_token_with_expiry( + lighter.SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY + ) + + response = requests.post( + f"{BASE_URL}/api/v1/changeAccountTier", + data={"account_index": ACCOUNT_INDEX, "new_tier": "premium"}, + headers={"Authorization": auth}, + ) + if response.status_code != 200: + print(f"Error: {response.text}") + return + print(response.json()) + + +if __name__ == "__main__": + asyncio.run(main())