evm-token-decimals

Query ERC-20 token decimals and normalize balances to 18 decimals.

1|Updated Apr 6, 2026
One-click install
npx skills add https://github.com/vrcms/everything-qwen-code --skill evm-token-decimals-vrcms
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: evm-token-decimals
Source: https://github.com/vrcms/everything-qwen-code/tree/main/.qwen/skills/evm-token-decimals
Command: npx skills add https://github.com/vrcms/everything-qwen-code --skill evm-token-decimals-vrcms

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires web3, ethers.

What problem does it solve?

This Skill prevents critical financial errors caused by assuming tokens share the same decimal precision, which often leads to balance or valuation inaccuracies by orders of magnitude.

Core Features & Use Cases

  • Runtime Precision Lookup: Dynamically queries the decimals() function of any ERC-20 token to ensure accurate math.
  • Defensive Caching: Implements chain-aware caching to optimize performance while maintaining data integrity.
  • Use Case: When building a DeFi dashboard or trading bot, use this to normalize token balances to a standard WAD (18 decimals) before performing any arithmetic or fiat conversion.

Quick Start

Use the evm-token-decimals skill to verify the decimal precision for the token at address 0x123... on the Ethereum mainnet.

Frequently Asked Questions about evm-token-decimals

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I normalize ERC-20 token balances to 18 decimals for DeFi calculations?

To normalize ERC-20 token balances to 18 decimals, you can dynamically query the token's decimals() function and mathematically adjust the balance without floating-point operations to ensure exact precision.

Why do my hardcoded ERC-20 token balance calculations show orders of magnitude errors?

Hardcoded token balance calculations show magnitude errors because tokens have varying decimal precision. Querying the actual decimals at runtime prevents assuming standard precision and avoids critical financial calculation inaccuracies.

Does web3 or ethers support querying token decimals across different EVM chains?

Yes, web3 and ethers support querying token decimals across EVM chains, and using a chain-aware caching mechanism optimizes performance while maintaining data integrity for your financial applications.

What's the best way to prevent silent decimal mismatch bugs in EVM trading bots?

The best way to prevent silent decimal mismatch bugs in EVM trading bots is implementing runtime precision lookup to dynamically query and normalize ERC-20 balances before executing any arithmetic or fiat conversions.

When do I need to query token decimals dynamically instead of assuming 18 decimals?

You need to query token decimals dynamically whenever building DeFi dashboards or bots to prevent valuation inaccuracies, as assuming all tokens share 18 decimal precision leads to critical financial calculation errors.