Skip to content

get_token_accounts_by_owner_json_parsed is not returning SOL balance #428

Open
@Aviksaikat

Description

As mentioned here #48 I'm doing the following the get the token balance of a token account

opts = TokenAccountOpts(program_id=Pubkey.from_string('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'))
data = http_client.get_token_accounts_by_owner_json_parsed(addr,  opts)
print(data)
GetTokenAccountsByOwnerJsonParsedResp {
   context: RpcResponseContext {
      slot: 266082342,
      api_version: Some(
         "1.17.28",
      ),
   },
   value: [
      RpcKeyedAccountJsonParsed {
         pubkey: Pubkey(
            DDbasA38QbfNA3newPNSi7ecNSuX2mocuXQBTEb4oPw4,
         ),
         account: AccountJSON {
            lamports: 2039280,
            data: ParsedAccount(
               ParsedAccount {
                  program: "spl-token",
                  parsed: Object {
                     "info": Object {
                        "isNative": Bool(false),
                        "mint": String("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),
                        "owner": String("addr"),
                        "state": String("initialized"),
                        "tokenAmount": Object {
                           "amount": String("14322586"),
                           "decimals": Number(6),
                           "uiAmount": Number(14.322586),
                           "uiAmountString": String("14.322586"),                     },                  },
                     "type": String("account"),               },
                  space: 165,            },
            ),
            owner: Pubkey(
               TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA,
            ),
            executable: false,
            rent_epoch: 18446744073709551615,      },   },
      RpcKeyedAccountJsonParsed {
         pubkey: Pubkey(
            9S7bZeawU8UM2ez5oZWC5ye2f3xJZNsCKFFEZHa1kPTz,
         ),
         account: AccountJSON {
            lamports: 2039280,
            data: ParsedAccount(
               ParsedAccount {
                  program: "spl-token",
                  parsed: Object {
                     "info": Object {
                        "isNative": Bool(false),
                        "mint": String("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
                        "owner": String("addr"),
                        "state": String("initialized"),
                        "tokenAmount": Object {
                           "amount": String("1430977"),
                           "decimals": Number(6),
                           "uiAmount": Number(1.430977),
                           "uiAmountString": String("1.430977"),                     },                  },
                     "type": String("account"),               },
                  space: 165,            },
            ),
            owner: Pubkey(
               TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA,
            ),
            executable: false,
            rent_epoch: 18446744073709551615,      },   },
   ],
}

This is my account that I'm fetching

image

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