Agent skill · software engineering · affaan-m

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 off by orders of magnitude.

Why this skill is useful

Provides domain-specific knowledge on handling ERC-20 token decimals across EVM chains, including caching strategies and safe math practices.

What it needs

About 2k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

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 (chainid, tokenaddress), and use decimal-safe math for value calculations. Examples Query decimals at runtime Do not hardcode 1000000 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

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/evm-token-decimals--347dd8

View the source on GitHub

Browse the @skills marketplace