What does this skill do?

The EVM Safe Decimals Skill prevents silent magnitude errors in balances and fiat values caused by assuming fixed decimals for ERC-20 tokens across multiple EVM networks. It checks the actual decimal places of each contract at runtime, implements a cache indexed by chain and token, and normalizes balances to a common base before comparing or valuing them. It ensures native precision in trading bots, portfolio trackers, and DeFi aggregators.

Reading ERC-20 Balances
Check exact balances in Python, TypeScript, or Solidity while preserving the native decimal places of each contract.
Management of Bridged Assets
Double-check the decimal places after a bridge or wrap, as the precision may vary between networks.
Calculation of Trust Value
Convert on-chain balances to fiat value without any significant deviations using arbitrary-precision types.
Multi-chain normalization
Convert balances to a common base (WAD with 18 decimal places) before comparing or adding them across different EVM networks.

Usage examples

💰 Calculating the Exact Change in Python
Read the USDC token balance at the address 0x... in my wallet using web3.py and return the value with the correct number of decimal places.
🌉 Bridged token
This token has been bridged from Ethereum to Polygon. Please check the contract's decimal places on Polygon again before calculating the value.
📊 Compare Across Chains
Normalize the balances of three ERC-20 tokens from different networks to WAD (18 decimal places) and compare them on a dashboard.
🤖 Trading bot
Implement a decimal cache indexed by chain_id and token_address for my multi-chain trading bot.

Features

Real-Time Query Call the contract's `decimals()` function on every execution; never assume 6 or 18 decimal places by default.
Multidimensional cache A cache system indexed by (chain_id, token_address) rather than by symbol, preventing collisions between networks.
Mathematics of Arbitrary Precision Use `Decimal` in Python and `BigInt` in JS/TS for calculations to avoid floating-point errors.
Management of bridges and wraps Detects bridged or wrapped tokens and rechecks the decimals after the network bridge.
Safe fallback for non-standard tokens If the `decimals()` call returns a value, it applies 18 by default and logs a visible warning for manual review.

Frequently asked questions

Yes. You need access to an RPC node (Infura, Alchemy, QuickNode, or your own) so that the skill can query the on-chain contracts and obtain the actual decimal places for each token.
The skill includes examples and patterns for Python (web3.py), TypeScript (ethers), and Solidity, covering the most common stacks in EVM development.
The skill applies a safe default value (usually 18) and logs a visible warning so that you can review that token manually.
Because the same symbol (e.g., USDC) can have different decimal places on different networks. The cache is indexed by (chain_id, token_address) to prevent errors.
EVM-Secure Decimals — On-Chain Accuracy with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.