evm-token-decimals
Prevent silent decimal mismatch bugs across EVM chains. Covers runtime decimal lookup, chain-aware caching, bridged-token precision drift, and safe normalization for bots, dashboards, and DeFi tools. Use when handling token amounts across EVM chains, or when a balance, price, or transfer amount is o
By affaan-m · 2,805 installs
npx skills add affaan-m/ecc --skill evm-token-decimals
Source repository · Upstream listing
EVM Token Decimals
Silent decimal mismatches are one of the easiest ways to ship balances or USD values that are off by orders of magnitude without throwing an error.
When to Use
Reading ERC 20 balances in Python, TypeScript, or Solidity
Calculating fiat values from on chain balances
Comparing token amounts across multiple EVM chains
Handling bridged assets
Building portfolio trackers, bots, or aggregators
How It Works
Never assume stablecoins use the same decimals everywhere. Query decimals() at runtime, cache by (chain id, token address) , and use decimal safe math for value calculations.
Examples
Query decimals at runtime
Do not hardcode 1 000 000 because a symbol usually has 6 decimals somewhere else.
Cache by chain and token
Handle odd tokens defensively
Log the fallback and keep it visible. Old or non standard tokens still exist.
Normalize to 18 decimal WAD in Solidity
TypeScript with ethers
Quick on chain check
Rules
Always query decimals() at runtime
Cache by chain plus token address, not symbol
Use Decimal , BigInt , or equivalent exact math, not float
Re query decimals after bridging or wrapper changes
Normalize internal accounting consistently before comparison or pricing