affaan-m avatar

Evm Token Decimals

If you've ever shipped a dashboard where USDC balances looked fine on Ethereum but were off by a factor of a million on Solana-bridged versions, this is for you. It walks through runtime decimal lookups, chain-aware caching, and safe normalization patterns in Python, TypeScript, and Solidity. The examples cover defensive fallbacks for non-standard tokens, normalization to 18-decimal WAD, and the critical rule of caching by chain ID plus address instead of symbol. It's a narrow skill but solves a class of bug that's silent until users notice their portfolio tracker is wildly wrong.

skills.sh installs
5.4K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

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

Installs into .claude/skills of the current project.

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"},
]

Sponsors

Details

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

More from affaan-m/ecc

All 263
1trailofbits avatardimensional-analysistrailofbits/skillsAnnotates codebases with dimensional analysis comments documenting units, dimensions, and decimal scaling. Use when someone asks to annotate units in a codebase4.6Kskills.sh installs
2inngest avatarinngest-eventsinngest/inngest-skillsUse when designing event-driven workflows, decoupling services, implementing fan-out patterns (one trigger, many downstream handlers), implementing idempotent e4Kskills.sh installs
3raroque avatarvibe-securityraroque/vibe-security-skillAudits codebases for common security vulnerabilities that AI coding assistants introduce in "vibe-coded" applications. Checks for exposed API keys, broken acces3.8Kskills.sh installs
4anthropics avatarvariance-analysisanthropics/knowledge-work-pluginsDecompose financial variances into drivers with narrative explanations and waterfall analysis. Use when analyzing budget vs. actual, period-over-period changes,3.4Kskills.sh installs
5dpearson2699 avatarcryptokitdpearson2699/swift-ios-skillsUse Apple CryptoKit for Swift cryptographic primitives. Use when hashing with SHA-2 or SHA-3, generating HMACs, encrypting with AES-GCM or ChaChaPoly, signing w3.3Kskills.sh installs
6dpearson2699 avatarfinancekitdpearson2699/swift-ios-skillsAccess eligible Wallet financial data using FinanceKit and FinanceKitUI. Use when querying transactions or balances, reading Apple Card, Apple Cash, Savings, or3.2Kskills.sh installs