Documentation Index
Fetch the complete documentation index at: https://docs.getpara.com/llms.txt
Use this file to discover all available pages before exploring further.
Query XLM and token balances for your connected Para wallet or any Stellar address using the Horizon API.
Query Balances
import { useState } from "react";
import { useParaStellarSigner } from "@getpara/react-native-wallet/stellar";
import { Horizon, Networks } from "@stellar/stellar-sdk";
import { View, Text, Button } from "react-native";
const server = new Horizon.Server("https://horizon.stellar.org");
function BalanceDisplay() {
const { stellarSigner, isLoading } = useParaStellarSigner({
networkPassphrase: Networks.PUBLIC,
});
const [balances, setBalances] = useState<{ asset: string; balance: string }[]>([]);
const queryBalances = async () => {
if (!stellarSigner) return;
const account = await server.loadAccount(stellarSigner.address);
const parsed = account.balances.map((b) => {
if (b.asset_type === "native") {
return { asset: "XLM", balance: b.balance };
}
return { asset: `${b.asset_code}:${b.asset_issuer}`, balance: b.balance };
});
setBalances(parsed);
console.log("Balances:", parsed);
};
if (isLoading) return <Text>Loading...</Text>;
return (
<View>
<Text>Address: {stellarSigner?.address}</Text>
<Button title="Query Balances" onPress={queryBalances} />
{balances.map((b) => (
<View key={b.asset}>
<Text>{b.balance} {b.asset}</Text>
</View>
))}
</View>
);
}
Query a Specific Asset
import { Horizon } from "@stellar/stellar-sdk";
async function getAssetBalance(address: string, assetCode: string, assetIssuer: string) {
const server = new Horizon.Server("https://horizon.stellar.org");
const account = await server.loadAccount(address);
const match = account.balances.find(
(b) => b.asset_type !== "native" && b.asset_code === assetCode && b.asset_issuer === assetIssuer
);
return match ? match.balance : "0";
}
// Example: Check USDC balance
const usdcBalance = await getAssetBalance(
"GABCD...",
"USDC",
"GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"
);
A balance of "0" for a custom asset means the account has a trustline but no tokens. If find returns undefined, the account has no trustline for that asset and cannot receive it until one is created. See Execute Transactions for how to add trustlines.
Next Steps