Skip to content

getTokenDecimals()

SIP Protocol API Reference v0.7.4


SIP Protocol API Reference / getTokenDecimals

getTokenDecimals(symbol, chain): number

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:7081

Get token decimals by symbol and chain

string

Token symbol (e.g., ‘USDC’, ‘SOL’, ‘ETH’)

ChainId

Chain identifier

number

Number of decimals for the token

If token is unknown

// Correct usage - always lookup decimals
const decimals = getTokenDecimals('USDC', 'solana') // 6
const solDecimals = getTokenDecimals('SOL', 'solana') // 9
const ethDecimals = getTokenDecimals('ETH', 'ethereum') // 18
// This prevents the common bug of hardcoding 9:
// WRONG: decimals: 9
// RIGHT: decimals: getTokenDecimals(symbol, chain)