Oracle
useGetTokenUsdPrice
useGetTokenUsdPrice
A React hook that fetches the current USD price for supported tokens (B3TR, VET, VTHO) from the VeChain oracle contract.
Usage
Parameters
Fetch the price for the following token symbols: 'B3TR', 'VET', 'VTHO'.
Returns
The hook returns a TanStack Query result object with the following properties:
data
number
The current token price in USD.
isLoading
boolean
Indicates if the query is currently loading.
error
Error | null
Describes any error that occurred during query.
isError
boolean
Indicates if there was an error in the query.
Implementation Details
The hook internally:
Uses the VeChain oracle contract to fetch real-time price data
Automatically handles network configuration (mainnet/testnet)
Caches results using TanStack Query
Only fetches when both Thor connection and network type are available
Example with Multiple Tokens
Last updated
Was this helpful?