
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-codeInstalls 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- Perl Patterns5.4K
- Quarkus Tdd5.4K
- Quarkus Verification5.4K
- Ralphinho Rfc Pipeline5.4K
- Perl Testing5.4K
- Nanoclaw Repl5.4K
- Messages Ops5.4K
- Recsys Pipeline Architect5.4K
- Latency Critical Systems5.3K
- Fsharp Testing5.3K
- Tinystruct Patterns5.3K
- Uncloud5.3K
- Parallel Execution Optimizer5.3K
- Prediction Market Oracle Research5.3K
- Prediction Market Risk Review5.3K
- Data Throughput Accelerator5.3K
- Recursive Decision Ledger5.3K
- Team Agent Orchestration5.1K
- Dynamic Workflow Mode5K
- Kubernetes Patterns4.9K
- Intent Driven Development4.8K
- Inherit Legacy Style4.8K
- Orch Build Mvp4.8K
- Codehealth Mcp4.8K