Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i get secret key for subacount? #175

Open
devdjangoreact opened this issue Feb 18, 2025 · 1 comment
Open

how can i get secret key for subacount? #175

devdjangoreact opened this issue Feb 18, 2025 · 1 comment

Comments

@devdjangoreact
Copy link

after creating access keys to the sub account, you need to get the deposit address

is it possible to get the sub account replenishment address through the main account keys?

`import gate_api
import os
from gate_api.exceptions import ApiException, GateApiException
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("GATE_API_KEY")
API_SECRET = os.getenv("GATE_API_SECRET")

configuration = gate_api.Configuration(key=API_KEY, secret=API_SECRET)
api_client = gate_api.ApiClient(configuration)

sub_account_api = gate_api.SubAccountApi(api_client)

token = "TON"
network = "TON"

try:
sub_accounts = sub_account_api.list_sub_accounts()
for sub_account in sub_accounts:
api_keys = sub_account_api.list_sub_account_keys(sub_account.user_id)
api_keys = sub_account_api.get_sub_account_key(sub_account.user_id,key="some key")
if not api_keys:
sub_account_key = gate_api.SubAccountKey(ip_whitelist=["176.110.0.0/16"])
api_keys = sub_account_api.create_sub_account_keys(
sub_account.user_id, sub_account_key
)
print(f"Created API key for Sub Account: {sub_account.login_name}")

for api_key in api_keys:

    sub_configuration = gate_api.Configuration(
        key=api_key.key, secret=????? - HOW CAN I GET SECRET KEY SUBACCOUNT?
    )
    sub_api_client = gate_api.ApiClient(sub_configuration)
    sub_wallet_api = gate_api.WalletApi(sub_api_client)


    deposit_address = sub_wallet_api.get_deposit_address(currency=token)
    print(
        f"Sub Account: {sub_account.user_id}, Deposit Address for {token} on {network}: {deposit_address.address}"
    )

except GateApiException as e:
print(f"Gate API Exception: {e}")
except ApiException as e:
print(f"API Exception: {e}")`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@devdjangoreact and others