Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt

Use this file to discover all available pages before exploring further.

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 'oms-client-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.
contractAddressstringToken contract address to query.
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.
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 'oms-client-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.