How to query contract token balance by owner address?

how to query contract token balance by address(not contract address)?
I didn’t find the right API interface

Hi @yifanes ,
One user may own many different tokens (different contract addresses).
So checking a token balance without having it’s contract address seems to be impossible :slight_smile:

Could you please provide more details about your case?

Hi I didn’t describe my problem clearly.
I want to:
input: user address + contract address
output: The balance of the corresponding contract in this user

hey, you can use to query this info.
below is the example of querying MIR balance (contract terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6) of the address terra14k38ap56s7k7hmdpf9lxkfacztn7fwd28a58rj on

query {
    ContractAddress: "terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6",
    QueryMsg: "{\"balance\":{\"address\":\"terra14k38ap56s7k7hmdpf9lxkfacztn7fwd28a58rj\"}}") {

you can also send a POST request to get this info, a code snippet is below

const mantleUrlMainnet = "";
const mirContractAddress = "terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6";
const walletAddress = "terra14k38ap56s7k7hmdpf9lxkfacztn7fwd28a58rj";
const axiosBody = {
      "operationName": null,
      "variables": {},
      "query": "{\n" +
        "mirBalance:WasmContractsContractAddressStore(" +
        "ContractAddress: \"" + mirContractAddress + "\", QueryMsg: \"{" +
        "\\\"balance\\\":{\\\"address\\\":\\\"" + walletAddress + "\\\"}}\"){" +
        "\n Result\n}\n" +

const results = await, axiosBody);