Skip to content

how to figure out the number of decimals? #100

@chiwalfrm

Description

@chiwalfrm

Using the method get_token_balance(address=my_address) to get the token balance for an address, the output does not take into account the number of decimals. For example:
fetching USDC (contract address 0xdac17f958d2ee523a2206206994597c13d831ec7) token balance returns a number that needs to be divided by 1e+6 (i.e. 6 decimal places):

Result: {"status":"1","message":"OK","result":"87000000000"} --> actual value = 87,000

But for many other tokens, it needs to be divided by 1e+18:
For example, for aWETH (contract address 0x030ba81f1c18d280636f32af80b9aad02cf0854e):

Result: {"status":"1","message":"OK","result":"200004568518412516545"} --> actual value = 200.004568518412516545

Question is how can we know the divisor / i.e. how many decimals is in the result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions