[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F0124TEP7ASVM0FX8B72DA":3,"skill-same:01M7F0124TEP7ASVM0FX8B72DA":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":14,"repositoryHtmlUrl":30,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7F0124TEP7ASVM0FX8B72DA","evm-token-decimals",null,"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. Use when handling token amounts across EVM chains, or when a balance, price, or transfer amount is off by orders of magnitude.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fecc\u002Fevm-token-decimals\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: evm-token-decimals\ndescription: 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. Use when handling token amounts across EVM chains, or when a balance, price, or transfer amount is off by orders of magnitude.\nmetadata:\n  version: \"1.0.0\"\n  origin: ECC direct-port adaptation\n---\n\n# EVM Token Decimals\n\nSilent 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.\n\n## When to Use\n\n- Reading ERC-20 balances in Python, TypeScript, or Solidity\n- Calculating fiat values from on-chain balances\n- Comparing token amounts across multiple EVM chains\n- Handling bridged assets\n- Building portfolio trackers, bots, or aggregators\n\n## How It Works\n\nNever 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.\n\n## Examples\n\n### Query decimals at runtime\n\n```python\nfrom decimal import Decimal\nfrom web3 import Web3\n\nERC20_ABI = [\n    {\"name\": \"decimals\", \"type\": \"function\", \"inputs\": [],\n     \"outputs\": [{\"type\": \"uint8\"}], \"stateMutability\": \"view\"},\n    {\"name\": \"balanceOf\", \"type\": \"function\",\n     \"inputs\": [{\"name\": \"account\", \"type\": \"address\"}],\n     \"outputs\": [{\"type\": \"uint256\"}], \"stateMutability\": \"view\"},\n]\n\ndef get_token_balance(w3: Web3, token_address: str, wallet: str) -> Decimal:\n    contract = w3.eth.contract(\n        address=Web3.to_checksum_address(token_address),\n        abi=ERC20_ABI,\n    )\n    decimals = contract.functions.decimals().call()\n    raw = contract.functions.balanceOf(Web3.to_checksum_address(wallet)).call()\n    return Decimal(raw) \u002F Decimal(10 ** decimals)\n```\n\nDo not hardcode `1_000_000` because a symbol usually has 6 decimals somewhere else.\n\n### Cache by chain and token\n\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=512)\ndef get_decimals(chain_id: int, token_address: str) -> int:\n    w3 = get_web3_for_chain(chain_id)\n    contract = w3.eth.contract(\n        address=Web3.to_checksum_address(token_address),\n        abi=ERC20_ABI,\n    )\n    return contract.functions.decimals().call()\n```\n\n### Handle odd tokens defensively\n\n```python\ntry:\n    decimals = contract.functions.decimals().call()\nexcept Exception:\n    logging.warning(\n        \"decimals() reverted on %s (chain %s), defaulting to 18\",\n        token_address,\n        chain_id,\n    )\n    decimals = 18\n```\n\nLog the fallback and keep it visible. Old or non-standard tokens still exist.\n\n### Normalize to 18-decimal WAD in Solidity\n\n```solidity\ninterface IERC20Metadata {\n    function decimals() external view returns (uint8);\n}\n\nfunction normalizeToWad(address token, uint256 amount) internal view returns (uint256) {\n    uint8 d = IERC20Metadata(token).decimals();\n    if (d == 18) return amount;\n    if (d \u003C 18) return amount * 10 ** (18 - d);\n    return amount \u002F 10 ** (d - 18);\n}\n```\n\n### TypeScript with ethers\n\n```typescript\nimport { Contract, formatUnits } from 'ethers';\n\nconst ERC20_ABI = [\n  'function decimals() view returns (uint8)',\n  'function balanceOf(address) view returns (uint256)',\n];\n\nasync function getBalance(provider: any, tokenAddress: string, wallet: string): Promise\u003Cstring> {\n  const token = new Contract(tokenAddress, ERC20_ABI, provider);\n  const [decimals, raw] = await Promise.all([\n    token.decimals(),\n    token.balanceOf(wallet),\n  ]);\n  return formatUnits(raw, decimals);\n}\n```\n\n### Quick on-chain check\n\n```bash\ncast call \u003Ctoken_address> \"decimals()(uint8)\" --rpc-url \u003Crpc>\n```\n\n## Rules\n\n- Always query `decimals()` at runtime\n- Cache by chain plus token address, not symbol\n- Use `Decimal`, `BigInt`, or equivalent exact math, not float\n- Re-query decimals after bridging or wrapper changes\n- Normalize internal accounting consistently before comparison or pricing\n","# EVM Token Decimals\n\nSilent 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.\n\n## When to Use\n\n- Reading ERC-20 balances in Python, TypeScript, or Solidity\n- Calculating fiat values from on-chain balances\n- Comparing token amounts across multiple EVM chains\n- Handling bridged assets\n- Building portfolio trackers, bots, or aggregators\n\n## How It Works\n\nNever 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.\n\n## Examples\n\n### Query decimals at runtime\n\n```python\nfrom decimal import Decimal\nfrom web3 import Web3\n\nERC20_ABI = [\n    {\"name\": \"decimals\", \"type\": \"function\", \"inputs\": [],\n     \"outputs\": [{\"type\": \"uint8\"}], \"stateMutability\": \"view\"},\n    {\"name\": \"balanceOf\", \"type\": \"function\",\n     \"inputs\": [{\"name\": \"account\", \"type\": \"address\"}],\n     \"outputs\": [{\"type\": \"uint256\"}], \"stateMutability\": \"view\"},\n]\n\ndef get_token_balance(w3: Web3, token_address: str, wallet: str) -> Decimal:\n    contract = w3.eth.contract(\n        address=Web3.to_checksum_address(token_address),\n        abi=ERC20_ABI,\n    )\n    decimals = contract.functions.decimals().call()\n    raw = contract.functions.balanceOf(Web3.to_checksum_address(wallet)).call()\n    return Decimal(raw) \u002F Decimal(10 ** decimals)\n```\n\nDo not hardcode `1_000_000` because a symbol usually has 6 decimals somewhere else.\n\n### Cache by chain and token\n\n```python\nfrom functools import lru_cache\n\n@lru_cache(maxsize=512)\ndef get_decimals(chain_id: int, token_address: str) -> int:\n    w3 = get_web3_for_chain(chain_id)\n    contract = w3.eth.contract(\n        address=Web3.to_checksum_address(token_address),\n        abi=ERC20_ABI,\n    )\n    return contract.functions.decimals().call()\n```\n\n### Handle odd tokens defensively\n\n```python\ntry:\n    decimals = contract.functions.decimals().call()\nexcept Exception:\n    logging.warning(\n        \"decimals() reverted on %s (chain %s), defaulting to 18\",\n        token_address,\n        chain_id,\n    )\n    decimals = 18\n```\n\nLog the fallback and keep it visible. Old or non-standard tokens still exist.\n\n### Normalize to 18-decimal WAD in Solidity\n\n```solidity\ninterface IERC20Metadata {\n    function decimals() external view returns (uint8);\n}\n\nfunction normalizeToWad(address token, uint256 amount) internal view returns (uint256) {\n    uint8 d = IERC20Metadata(token).decimals();\n    if (d == 18) return amount;\n    if (d \u003C 18) return amount * 10 ** (18 - d);\n    return amount \u002F 10 ** (d - 18);\n}\n```\n\n### TypeScript with ethers\n\n```typescript\nimport { Contract, formatUnits } from 'ethers';\n\nconst ERC20_ABI = [\n  'function decimals() view returns (uint8)',\n  'function balanceOf(address) view returns (uint256)',\n];\n\nasync function getBalance(provider: any, tokenAddress: string, wallet: string): Promise\u003Cstring> {\n  const token = new Contract(tokenAddress, ERC20_ABI, provider);\n  const [decimals, raw] = await Promise.all([\n    token.decimals(),\n    token.balanceOf(wallet),\n  ]);\n  return formatUnits(raw, decimals);\n}\n```\n\n### Quick on-chain check\n\n```bash\ncast call \u003Ctoken_address> \"decimals()(uint8)\" --rpc-url \u003Crpc>\n```\n\n## Rules\n\n- Always query `decimals()` at runtime\n- Cache by chain plus token address, not symbol\n- Use `Decimal`, `BigInt`, or equivalent exact math, not float\n- Re-query decimals after bridging or wrapper changes\n- Normalize internal accounting consistently before comparison or pricing\n",{"name":5,"metadata":24,"description":7},{"origin":25,"version":26},"ECC direct-port adaptation","1.0.0","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fecc\u002Fevm-token-decimals","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill evm-token-decimals",{"tool":39,"command":40},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill evm-token-decimals",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill evm-token-decimals","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fecc\u002Fevm-token-decimals\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]