affaan-m/ECC

evm-token-decimals

EVMチェーン全体でサイレントな小数点不一致バグを防ぐ。ランタイムでの小数点照会、チェーン対応キャッシング、ブリッジドトークンの精度ドリフト、ボット・ダッシュボード・DeFiツール向けの安全な正規化をカバーします。

64Collecting
See how to use itView GitHub source
npx skills add https://github.com/affaan-m/ECC --skill "docs/ja-JP/skills/evm-token-decimals"
Automated source guide

Source checked Jul 28, 2026·Refresh due Oct 26, 2026

Reorganized from the pinned upstream SKILL.md

Turn evm-token-decimals's source instructions into a guide you can follow

According to the pinned SKILL.md from affaan-m/ECC: サイレントな小数点不一致は、エラーを発生させることなく残高やUSD値が桁違いになる最も簡単な方法のひとつです。

npx skills add https://github.com/affaan-m/ECC --skill "docs/ja-JP/skills/evm-token-decimals"
Check the pinned source

Best fit

  • EVMチェーン全体でサイレントな小数点不一致バグを防ぐ。ランタイムでの小数点照会、チェーン対応キャッシング、ブリッジドトークンの精度ドリフト、ボット・ダッシュボード・DeFiツール向けの安全な正規化をカバーします。

Bring this context

  • A concrete task that matches the documented purpose of evm-token-decimals.
  • The files, examples, or context the task depends on.
  • Your constraints, target environment, and definition of done.

Expected outputs

  • A result that follows the pinned evm-token-decimals instructions.
  • A concise record of assumptions, inputs used, and unresolved questions.
  • A final check against the source workflow and relevant permission signals.

Key source sections

Read evm-token-decimals through these 5 source sections

Sections are extracted automatically from the pinned SKILL.md and link back to the source.

01

使用するタイミング

Python、TypeScript、またはSolidityでERC-20残高を読み取る場合

SKILL.md · 使用するタイミング
Python、TypeScript、またはSolidityでERC-20残高を読み取る場合オンチェーン残高から法定通貨の値を計算する場合複数のEVMチェーン間でトークン量を比較する場合
02

仕組み

ステーブルコインが同じ小数点を使用していると仮定しないでください。ランタイムでdecimals()を照会し、(chainid, tokenaddress)でキャッシュし、値の計算には小数点安全な数学を使用します。

SKILL.md · 仕組み
ステーブルコインが同じ小数点を使用していると仮定しないでください。ランタイムでdecimals()を照会し、(chainid, tokenaddress)でキャッシュし、値の計算には小数点安全な数学を使用します。
03

使用例

シンボルが他の場所で通常6小数点を持つからといって1000000をハードコードしないでください。

SKILL.md · 使用例
シンボルが他の場所で通常6小数点を持つからといって1000000をハードコードしないでください。フォールバックをログに記録して可視化しておく。古いまたは非標準トークンはまだ存在します。
04

ランタイムで小数点を照会する

シンボルが他の場所で通常6小数点を持つからといって1000000をハードコードしないでください。

SKILL.md · ランタイムで小数点を照会する
シンボルが他の場所で通常6小数点を持つからといって1000000をハードコードしないでください。
05

チェーンとトークンでキャッシュする

Review the “チェーンとトークンでキャッシュする” section in the pinned source before continuing.

SKILL.md · チェーンとトークンでキャッシュする
Review and apply the “チェーンとトークンでキャッシュする” source section.

SkillSignal prompt templates

Provide the task, context, and acceptance criteria

These prompts were written by SkillSignal from the source structure; they are not upstream text.

Task-start prompt

Confirm source fit, inputs, and outputs before acting.

Use evm-token-decimals to help me with: [specific task]. Context: [files, data, or background]. Constraints: [environment, scope, and prohibited actions]. Before acting, check the pinned SKILL.md and explain which sections apply, what inputs are still missing, and what you will deliver.

Source-guided execution

Make the Agent explicitly follow the key extracted sections.

Apply the pinned evm-token-decimals source to [task]. Pay particular attention to these source sections: “使用するタイミング”, “仕組み”, “使用例”, “ランタイムで小数点を照会する”, “チェーンとトークンでキャッシュする”. Preserve the important decision at each step. Mark facts not covered by the source as “needs confirmation” instead of inventing them. Then verify the result against my acceptance criteria: [criteria].

Result-review prompt

Check omissions, permissions, and source drift before delivery.

Review the current evm-token-decimals result: (1) does it satisfy the original task; (2) were any applicable steps or limits in the pinned SKILL.md missed; (3) did it perform any unauthorized file, command, network, or data action; and (4) which conclusions remain unverified? List issues first, then fix only what the source or user authorization supports.

Output checklist

Verify each item before delivery

The task matches the purpose documented in the SKILL.md.

The source section “使用するタイミング” has been checked.

The source section “仕組み” has been checked.

The source section “使用例” has been checked.

The source section “ランタイムで小数点を照会する” has been checked.

Inputs, constraints, and acceptance criteria are explicit.

Unverified facts, compatibility, and outcome claims are clearly marked.

Any file, command, network, or data action has been reviewed.

Choose a different workflow

When another Skill is the better fit

FAQ

What does evm-token-decimals do?

サイレントな小数点不一致は、エラーを発生させることなく残高やUSD値が桁違いになる最も簡単な方法のひとつです。

How do I start using evm-token-decimals?

The catalog detected this source-specific install command: npx skills add https://github.com/affaan-m/ECC --skill "docs/ja-JP/skills/evm-token-decimals". Inspect the command and pinned source before running it.

Which Agent platforms does it declare?

No dedicated Agent platform is declared in the pinned source record.

Repository stars
234,327
Repository forks
35,711
Quality
64/100
Source repository last pushed

Quality breakdown

Based on traceable docs and repository signals; stars are not treated as quality.

64/100
Documentation21/30
Specificity11/25
Maintenance20/20
Trust signals12/25

Compare before choosing

Related Agent Skills and source variants

These links are selected from shared tasks, functions, stacks, platforms, and same-name variants. Compare the source owner, documentation, permissions, and maintenance signals.

evm-token-decimals by affaan-m

Prevent silent decimal mismatch bugs across EVM chains. Covers runtime decimal lookup, chain-aware caching, bridged-token precision drift, and safe normalization for bots, dashboards, and DeFi tools.

evm-token-decimals by affaan-m

防止跨EVM链的静默小数不匹配错误。涵盖运行时小数查找、链感知缓存、桥接代币精度漂移以及面向机器人、仪表盘和DeFi工具的安全归一化。

ab-testing by coreyhaines31

When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program

churn-prevention by coreyhaines31

When the user wants to reduce churn, build cancellation flows, set up save offers, recover failed payments, or implement retention strategies. Also use when the user mentions 'churn,' 'cancel flow,' 'offboarding,' 'save offer,' 'dunning,' 'failed payment recovery,' 'win-back,' 'retention,' 'exit survey,' 'pause subscription,' 'involuntary churn,' 'people keep canceling,' 'churn rate is too high,' 'how do I keep users,' or 'customers are leaving.' Use this whenever someone is losing subscribers o

design-intelligence by event4u-app

Grounded design brief from the adopted corpus — style, WCAG-checked color tokens, typography, layout pattern, anti-patterns. Use on ui-design-brief or any which-style/palette/font/chart decision.

View original Skill.mdThis page is parsed directly from the repository SKILL.md without editorial rewriting. Collected: Jul 28, 2026 · about 1 min

EVMトークン小数点

サイレントな小数点不一致は、エラーを発生させることなく残高やUSD値が桁違いになる最も簡単な方法のひとつです。

使用するタイミング

  • Python、TypeScript、またはSolidityでERC-20残高を読み取る場合
  • オンチェーン残高から法定通貨の値を計算する場合
  • 複数のEVMチェーン間でトークン量を比較する場合
  • ブリッジされた資産を扱う場合
  • ポートフォリオトラッカー、ボット、またはアグリゲーターを構築する場合

仕組み

ステーブルコインが同じ小数点を使用していると仮定しないでください。ランタイムでdecimals()を照会し、(chain_id, token_address)でキャッシュし、値の計算には小数点安全な数学を使用します。

使用例

ランタイムで小数点を照会する

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

def get_token_balance(w3: Web3, token_address: str, wallet: str) -> Decimal:
    contract = w3.eth.contract(
        address=Web3.to_checksum_address(token_address),
        abi=ERC20_ABI,
    )
    decimals = contract.functions.decimals().call()
    raw = contract.functions.balanceOf(Web3.to_checksum_address(wallet)).call()
    return Decimal(raw) / Decimal(10 ** decimals)

シンボルが他の場所で通常6小数点を持つからといって1_000_000をハードコードしないでください。

チェーンとトークンでキャッシュする

from functools import lru_cache

@lru_cache(maxsize=512)
def get_decimals(chain_id: int, token_address: str) -> int:
    w3 = get_web3_for_chain(chain_id)
    contract = w3.eth.contract(
        address=Web3.to_checksum_address(token_address),
        abi=ERC20_ABI,
    )
    return contract.functions.decimals().call()

特殊なトークンを防御的に処理する

try:
    decimals = contract.functions.decimals().call()
except Exception:
    logging.warning(
        "decimals() reverted on %s (chain %s), defaulting to 18",
        token_address,
        chain_id,
    )
    decimals = 18

フォールバックをログに記録して可視化しておく。古いまたは非標準トークンはまだ存在します。

SolidityでWAD(18小数点)に正規化する

interface IERC20Metadata {
    function decimals() external view returns (uint8);
}

function normalizeToWad(address token, uint256 amount) internal view returns (uint256) {
    uint8 d = IERC20Metadata(token).decimals();
    if (d == 18) return amount;
    if (d < 18) return amount * 10 ** (18 - d);
    return amount / 10 ** (d - 18);
}

ethersを使ったTypeScript

import { Contract, formatUnits } from 'ethers';

const ERC20_ABI = [
  'function decimals() view returns (uint8)',
  'function balanceOf(address) view returns (uint256)',
];

async function getBalance(provider: any, tokenAddress: string, wallet: string): Promise<string> {
  const token = new Contract(tokenAddress, ERC20_ABI, provider);
  const [decimals, raw] = await Promise.all([
    token.decimals(),
    token.balanceOf(wallet),
  ]);
  return formatUnits(raw, decimals);
}

クイックなオンチェーン確認

cast call <token_address> "decimals()(uint8)" --rpc-url <rpc>

ルール

  • 常にランタイムでdecimals()を照会する
  • シンボルではなく、チェーンとトークンアドレスでキャッシュする
  • floatではなくDecimalBigInt、または同等の正確な数学を使用する
  • ブリッジングやラッパーの変更後は小数点を再照会する
  • 比較や価格計算の前に内部会計を一貫して正規化する
Source repo
affaan-m/ECC
Skill path
docs/ja-JP/skills/evm-token-decimals/SKILL.md
Commit SHA
4e973d3eaf92
Repository license
MIT
Data collected