Skip to main content
Use oms.indexer to read balances and transaction history after creating OMSClient. Requests use the publishable key configured for the client, and token amounts are returned as raw base-unit strings. Pass explicit SDK OmsNetwork values with networks, or omit networks and use networkType. When both are omitted, networkType defaults to MAINNETS.

Get Balances

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

const walletAddress = await oms.wallet.getWalletAddress()

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

const polygon = oms.supportedNetworks.find((network) => network.chainId === '137')

const result = await oms.indexer.getBalances({
  walletAddress,
  networks: polygon ? [polygon] : undefined,
  contractAddresses: ['0x2222222222222222222222222222222222222222'],
  includeMetadata: true,
})

for (const balance of result.nativeBalances) {
  console.log(balance.symbol, formatUnits(balance.balance ?? '0', 18))
}

for (const balance of result.balances) {
  const decimals = balance.contractInfo?.decimals ?? 18
  console.log(balance.contractAddress, formatUnits(balance.balance ?? '0', decimals))
}
Parameters
ParameterTypeDescription
walletAddressstringWallet address to inspect. This can be the active wallet or any wallet address.
networksOmsNetwork[] or undefinedExplicit networks to query. Use values from oms.supportedNetworks.
networkType'MAINNETS', 'TESTNETS', 'ALL', or undefinedNetwork group to query when networks is omitted. Defaults to MAINNETS.
contractAddressesstring[] or undefinedOptional token contract addresses to query. Omit it to query balances across token contracts.
includeMetadataboolean or undefinedWhether token metadata should be included in the response. Defaults to true.
omitPricesboolean, null, or undefinedWhether price fields should be omitted.
tokenIdsstring[] or undefinedOptional token IDs to filter by.
contractStatus'VERIFIED', 'UNVERIFIED', 'ALL', null, or undefinedContract verification status filter.
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 oms.indexer.getBalances returns Promise<OmsBalancesResult>.
FieldTypeDescription
statusnumberHTTP status code from the balance response.
pageOmsTokenBalancesPage, null, or undefinedPagination metadata from the balance response.
nativeBalancesOmsTokenBalance[]Native token balances returned for the wallet.
balancesOmsTokenBalance[]Token contract balances returned for the wallet.

Get Transaction History

const walletAddress = await oms.wallet.getWalletAddress()

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

const amoy = oms.supportedNetworks.find((network) => network.chainId === '80002')

const result = await oms.indexer.getTransactionHistory({
  walletAddress,
  networks: amoy ? [amoy] : undefined,
  includeMetadata: true,
  page: {
    page: 0,
    pageSize: 25,
  },
})

for (const transaction of result.transactions) {
  console.log(transaction.txnHash, transaction.timestamp)
}
Parameters
ParameterTypeDescription
walletAddressstringWallet address to inspect. This can be the active wallet or any wallet address.
networksOmsNetwork[] or undefinedExplicit networks to query. Use values from oms.supportedNetworks.
networkType'MAINNETS', 'TESTNETS', 'ALL', or undefinedNetwork group to query when networks is omitted. Defaults to MAINNETS.
contractAddressesstring[] or undefinedOptional token contract addresses to filter by.
transactionHashesstring[] or undefinedOptional on-chain transaction hashes to filter by.
metaTransactionIdsstring[] or undefinedOptional wallet transaction ID filters, such as txnId returned by transaction APIs.
fromBlocknumber, null, or undefinedOptional lower block number bound.
toBlocknumber, null, or undefinedOptional upper block number bound.
tokenIdstring, null, or undefinedOptional token ID filter.
includeMetadataboolean or undefinedWhether token metadata should be included in the response. Defaults to true.
omitPricesboolean, null, or undefinedWhether price fields should be omitted.
metadataOptions.verifiedOnlyboolean or undefinedInclude metadata only for verified contracts.
metadataOptions.unverifiedOnlyboolean or undefinedInclude metadata only for unverified contracts.
metadataOptions.includeContractsstring[] or undefinedContract addresses for metadata inclusion.
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 oms.indexer.getTransactionHistory returns Promise<OmsTransactionHistoryResult>.
FieldTypeDescription
statusnumberHTTP status code from the transaction-history response.
pageOmsTokenBalancesPage, null, or undefinedPagination metadata from the transaction-history response.
transactionsOmsTransaction[]Transactions returned for the wallet.

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.
namestring, null, or undefinedToken name.
symbolstring, null, or undefinedToken symbol.
balancestring or nullRaw base-unit balance as a string.
balanceUSDstring, null, or undefinedBalance value in USD when prices are included.
priceUSDstring, null, or undefinedToken price in USD when prices are included.
priceUpdatedAtstring, null, or undefinedTimestamp for the price.
blockHashstring or nullBlock hash for the balance snapshot.
blockNumbernumber, null, or undefinedBlock number for the balance snapshot.
chainIdnumber, null, or undefinedNumeric chain ID.
uniqueCollectiblesstring, null, or undefinedUnique collectible count for NFT summary rows.
isSummaryboolean, null, or undefinedWhether the row summarizes a set of balances.
contractInfoOmsTokenContractInfo, null, or undefinedToken contract metadata when requested and available.
tokenMetadataOmsTokenMetadata, null, or undefinedToken metadata when requested and available.

Transaction Shape

Each OmsTransaction can include:
FieldTypeDescription
txnHashstring or nullOn-chain transaction hash.
blockNumbernumber or nullBlock number.
blockHashstring or nullBlock hash.
chainIdnumber or nullNumeric chain ID.
metaTxnIdstring, null, or undefinedWallet transaction ID when available.
transfersOmsTransactionTransfer[], null, or undefinedToken transfers included in the transaction.
timestampstring, null, or undefinedTransaction timestamp.