Skip to main content
Version: 1.16.1

Function: resolveTokenDecimals()

resolveTokenDecimals(chain: Chain, token: string, tokenPool?: string | (() => Promise<string | undefined>)): Promise<number>

Defined in: utils.ts:340

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, best-effort — only when the token view is missing, and a pool that cannot be resolved (e.g. an unregistered token) just falls through to the family default.

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).

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).