getTokenDecimals()
SIP Protocol API Reference v0.7.4
SIP Protocol API Reference / getTokenDecimals
Function: getTokenDecimals()
Section titled “Function: getTokenDecimals()”getTokenDecimals(
symbol,chain):number
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:7081
Get token decimals by symbol and chain
Parameters
Section titled “Parameters”symbol
Section titled “symbol”string
Token symbol (e.g., ‘USDC’, ‘SOL’, ‘ETH’)
Chain identifier
Returns
Section titled “Returns”number
Number of decimals for the token
Throws
Section titled “Throws”If token is unknown
Example
Section titled “Example”// Correct usage - always lookup decimalsconst decimals = getTokenDecimals('USDC', 'solana') // 6const solDecimals = getTokenDecimals('SOL', 'solana') // 9const ethDecimals = getTokenDecimals('ETH', 'ethereum') // 18
// This prevents the common bug of hardcoding 9:// WRONG: decimals: 9// RIGHT: decimals: getTokenDecimals(symbol, chain)