0

I'm trying to get the balance of a random USDT account in Solana. I've tried several public gateways and hasn't successed. Here's one example:

curl --request POST \
     --url https://solana-mainnet.g.alchemy.com/v2/demo \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
     "id": 1,
     "jsonrpc": "2.0",
     "method": "getTokenAccountBalance",
     "params": [
          "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
     ]
}
'

===>

{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid param: not a Token account"},"id":1}

Why is it "not a token account"? What's the matter?

Here's an account - https://solscan.io/account/TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

update 1

this address won't work either, resulting in the same error:

5Xm6nU1Bi6UewCrhJQFk1CAV97ZJaRiFw4tFNhUbXy3u

tutushka
  • 27
  • 6

1 Answers1

0

TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA is the Token Program itself and not a token account. This is a token account:

https://solscan.io/account/2SYZWm9WeCXb7LBX7dqXgk1dfF5Xa7wJobDSLos8urXp

  • `5Xm6nU1Bi6UewCrhJQFk1CAV97ZJaRiFw4tFNhUbXy3u` is an address. Why won't it work? The same error – tutushka Nov 05 '22 at 03:41
  • That address is a system account, not a token account: https://solscan.io/account/5Xm6nU1Bi6UewCrhJQFk1CAV97ZJaRiFw4tFNhUbXy3u -- however, here's a token account owned by that address: https://solscan.io/account/HvPrEbe7USoA3VuZUMm79rks54Pofdqi7MTR41YTZLg5 – Jon C Nov 10 '22 at 22:31