Skip to main content
Version: 1.16.1

Function: resolveTokenDecimals()

resolveTokenDecimals(chain: Chain, token: string, tokenPool?: string | (() => Promise<string | undefined>), __namedParameters?: { familyDefault?: boolean; }): Promise<number>

Defined in: utils.ts:343

Resolve a token's decimals with the standard fallback chain every preflight uses when it must convert or compare amounts: the token's own (optional) ERC-20 decimals() view first; when the token doesn't implement it, the decimals its pool declares (TokenPoolConfig.decimals, pool v1.5.1+) — the authoritative fallback, since the pool uses exactly these decimals for its own conversion; else the chain family's static default (ChainStatic.decimals, e.g. 18 on EVM) — its native token's, which the vast majority of the family's tokens share.

The pool is resolved lazily — only when the token view is missing. A resolver returning undefined (no pool to resolve, e.g. no router/offRamp to resolve it from) falls through to the family default; a resolver that throws propagates, so transport failures (e.g. a registry TIMEOUT) surface instead of silently triggering the fallback.

Parameters​

ParameterTypeDescription
chainChainChain to resolve the decimals on.
tokenstringToken address.
tokenPool?string | (() => Promise<string | undefined>)The token's pool address, or a lazy resolver for it (called only when the token view is missing).
__namedParameters?{ familyDefault?: boolean; }-
__namedParameters.familyDefault?boolean-

Returns​

Promise<number>

The resolved decimals.

Throws​

The token view's CCIPTokenDecimalsUnavailableError when neither the pool nor the family default can declare them (e.g. an unregistered family).