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 to check asset amount in wallet? #22

Closed
majestique opened this issue Jan 6, 2022 · 3 comments
Closed

How to check asset amount in wallet? #22

majestique opened this issue Jan 6, 2022 · 3 comments

Comments

@majestique
Copy link

thinking i may have to use algod for this? i want to keep purchasing an asset until I spend all ALGO, I don't want to purchase it all at once because slippage will be too high

@majestique majestique changed the title How to check asset amount in my wallet? How to check asset amount in wallet? Jan 6, 2022
@efe
Copy link
Contributor

efe commented Jan 17, 2022

You can use account_info in py-algorand-sdk. https://py-algorand-sdk.readthedocs.io/en/latest/algosdk/algod.html#algosdk.algod.AlgodClient.account_info

BTW, Wallet does not have asset or algo. Account has.

@ctubio
Copy link

ctubio commented Jan 24, 2022

🎁

WALLET = {}

def get_wallet_asset_amount(asset, fetch=True):
  global WALLET
  if (fetch):
    WALLET = client.algod.account_info(client.user_address)
  try:
    return asset((next(
      item for item in WALLET['assets'] if item['asset-id'] == asset.id
    ) if asset.id else WALLET)['amount'])
  except:
    return asset(0)

@gokselcoban
Copy link
Contributor

Thank you for the question and answers. The issue looks like resolved.

I will close this issue, feel free to reopen it.

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

4 participants