Skip to content
affaan-m avatar

Evm Token Decimals

Prevents silent decimal mismatch bugs across EVM chains with runtime lookup, caching, and exact-math normalization.

CCM score
75 of 100
skills.sh installs
10.4K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers runtime decimals() lookup, chain-aware caching, bridged-token precision drift, and normalization for balances and USD values
  • Includes Python, TypeScript, and Solidity examples plus a cast call check for querying decimals on-chain
  • Enforces caching by chain ID and token address rather than symbol, and exact math with Decimal or BigInt instead of floats
  • Designed for bots, dashboards, portfolio trackers, and DeFi tools that compare token amounts across multiple chains

Install

$ npx -y skills add affaan-m/ecc --skill evm-token-decimals -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

from decimal import Decimal
from web3 import Web3

ERC20_ABI = [
    {"name": "decimals", "type": "function", "inputs": [],
     "outputs": [{"type": "uint8"}], "stateMutability": "view"},
    {"name": "balanceOf", "type": "function",
     "inputs": [{"name": "account", "type": "address"}],
     "outputs": [{"type": "uint256"}], "stateMutability": "view"},
]

Details

Repository
github.com/affaan-m/ecc
Categories
Web3 & Crypto, Finance & Trading
First seen
Jul 14, 2026

Questions

How do I stop token decimal mismatch bugs when reading EVM token balances?

The evm-token-decimals skill queries decimals() at runtime instead of assuming a fixed value, so a balance is not off by orders of magnitude. It caches the result by chain and token address and uses exact decimal math rather than floats.

What does the evm-token-decimals skill cover?

It covers runtime decimal lookup, chain-aware caching, bridged-token precision drift, and safe normalization for bots, dashboards, and DeFi tools. It includes examples in Python, TypeScript with ethers, and Solidity normalization to 18-decimal WAD.

How do I install evm-token-decimals?

Run npx -y skills add affaan-m/ecc --skill evm-token-decimals -y in your project. The skill then lets the agent write balance, USD value and transfer code that reads each token's decimals correctly.

Where does evm-token-decimals rank in the Web3 & Crypto category?

It ranks in the top 50 on the Web3 & Crypto category page on Claude Marketplaces. Its own description says it targets silent decimal bugs in cross-chain token amounts.

What if decimals() reverts on an older token?

The skill shows a defensive pattern that catches the revert, logs a warning with the token address and chain, and falls back to 18 decimals. It asks you to keep that fallback visible because non-standard tokens still exist.

More from affaan-m/ecc

All 257

Similar to Evm Token Decimals

More Web3 & Crypto