evm-token-decimals

Look up ERC-20 token decimals via runtime decimals() calls with chain-aware caching.

2|Updated May 11, 2026
One-click install
npx skills add https://github.com/himanshu231204/AI_Research_agent --skill evm-token-decimals-himanshu231204
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: evm-token-decimals
Source: https://github.com/himanshu231204/AI_Research_agent/tree/main/.opencode/skills/evm-token-decimals
Command: npx skills add https://github.com/himanshu231204/AI_Research_agent --skill evm-token-decimals-himanshu231204

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Silent decimal mismatches across EVM chains cause token balances and fiat valuations to be off by orders of magnitude without throwing any runtime errors, leading to financial loss or incorrect data in DeFi tools, bots, and dashboards.

Core Features & Use Cases

  • Runtime Decimal Lookup: Queries the on-chain decimals() function for every ERC-20 token instead of relying on hardcoded values.
  • Chain-Aware Caching: Caches decimal values by (chain_id, token_address) to reduce redundant on-chain calls.
  • Cross-Chain Precision Handling: Addresses decimal drift for bridged tokens and non-standard tokens with fallback logic and explicit logging.
  • Multi-Language Support: Provides implementation patterns for Python, TypeScript, and Solidity to support portfolio trackers, trading bots, DeFi aggregators, and fiat conversion tools.

Quick Start

Use the evm-token-decimals skill to calculate the correct USD value of an ERC-20 token balance on any EVM chain without hardcoding decimal values or risking magnitude errors.

Frequently Asked Questions about evm-token-decimals

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

FAQPage Schema
Why are my EVM token balances and fiat valuations off by orders of magnitude without throwing runtime errors?

Silent decimal mismatches across EVM chains cause token balances and fiat valuations to be off by orders of magnitude without throwing runtime exceptions. Querying the on-chain decimals() function for every ERC-20 token instead of relying on hardcoded values prevents these magnitude errors.

How do I handle ERC-20 decimal precision for bridged tokens across multiple EVM chains?

Handling ERC-20 decimal precision for bridged tokens requires cross-chain precision handling with fallback logic and explicit logging. Caching decimal values by chain_id and token_address reduces redundant on-chain calls while addressing decimal drift for non-standard bridged tokens.

Does this decimal-safe math approach work for both TypeScript trading bots and Python portfolio trackers?

The decimal-safe math approach works for TypeScript trading bots and Python portfolio trackers by providing multi-language implementation patterns. It supports DeFi aggregators and fiat conversion tools with consistent normalization for internal accounting workflows across Solidity, Python, and TypeScript environments.

What is the best way to calculate the correct USD value of an ERC-20 token balance on any EVM chain?

The best way to calculate USD value of an ERC-20 token balance is using runtime decimals() lookups combined with exact decimal-safe math. This avoids hardcoding decimal values and prevents magnitude errors when converting raw on-chain balances to fiat valuations.

When do I need runtime decimal lookups instead of hardcoded decimal values for ERC-20 tokens?

Runtime decimal lookups are needed when building DeFi tooling, cross-chain token comparisons, or bridged asset handling where non-standard tokens cause decimal drift. Hardcoded values fail silently for bridged tokens, leading to financial loss or incorrect dashboard data without runtime exceptions.