Skip to content

token: raw bytes reading for SPL token account balance #7

Description

@meditationduck

svm.token has the write side covered (transfer_checked, mint_to_checked,
create_ata, …) but there's no read side — getting a balance means unpacking
raw bytes:

int.from_bytes(Account(ata).data[64:72], "little")

The magic offset carries no meaning at the call site, and using it on the wrong
account (a wallet instead of a token account) returns plausible garbage rather
than failing.

It will be looks like, but not sure the best option, the original is still straight forward..

bob_bal = svm.token.account(bob_ata).amount

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions