Skip to main content
Use the React Native SDK balance helpers after configure. Requests use the project access key configured for the SDK, and balance amounts are returned as raw base-unit strings.

Get Token Balances

import {
  formatUnits,
  getTokenBalances,
  getWalletAddress,
} from '@0xsequence/oms-react-native-sdk'

const walletAddress = await getWalletAddress()

if (!walletAddress) {
  throw new Error('No active wallet session')
}

const result = await getTokenBalances({
  chainId: '137',
  contractAddress: '0xTokenContract',
  walletAddress,
  includeMetadata: true,
})

for (const balance of result.balances) {
  console.log(balance.contractAddress, formatUnits(balance.balance ?? '0', 6))
}
Parameters
ParameterTypeDescription
chainIdstringEVM chain ID as a string.
contractAddressstring or undefinedOptional token contract address to query. Omit it to query balances across token contracts.
walletAddressstringWallet address to inspect. This can be the active embedded wallet or any wallet address.
includeMetadataboolean or undefinedWhether token metadata should be included in the response. Defaults to false.
page.pagenumber or undefinedOptional page number. Defaults to 0 when page is omitted.
page.pageSizenumber or undefinedOptional page size. Defaults to the SDK response default when omitted.
Returns getTokenBalances returns Promise<OmsTokenBalancesResult>.
FieldTypeDescription
statusnumberHTTP status code from the balance response.
pageOmsTokenBalancesPage or undefinedPagination metadata from the balance response.
balancesOmsTokenBalance[]Balances returned for the wallet.

Get Native Token Balance

import { getNativeTokenBalance } from '@0xsequence/oms-react-native-sdk'

const nativeBalance = await getNativeTokenBalance({
  chainId: '80002',
  walletAddress,
})

console.log(nativeBalance?.balance)
Parameters
ParameterTypeDescription
chainIdstringEVM chain ID as a string.
walletAddressstringWallet address to inspect.
Returns getNativeTokenBalance returns Promise<OmsTokenBalance | null>. It returns null when the response does not include a native balance.

Token Balance Shape

Each OmsTokenBalance can include:
FieldTypeDescription
contractTypestring or nullToken contract type, such as ERC20, ERC721, or NATIVE.
contractAddressstring or nullToken contract address. Native token balances do not include a contract address.
accountAddressstring or nullWallet address queried.
tokenIdstring or nullToken ID for token types that use IDs.
balancestring or nullRaw base-unit balance as a string.
blockHashstring or nullBlock hash for the balance snapshot.
blockNumbernumber or nullBlock number for the balance snapshot.
chainIdnumber or nullNumeric chain ID.