[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78C3XSHTKP553W2992THWH3":3,"skill-same:01M78C3XSHTKP553W2992THWH3":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":26,"commitSha":27,"skillDirectory":28,"forksCount":14,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M78C3XSHTKP553W2992THWH3","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.","princepatel04477-web\u002Ftrivoxa-group","princepatel04477-web","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F227740714?v=4","01M788ZAJ2KECD5KXVP55PZXKS","Prince Patel","01M788ZAJTCN8YSD737MRSKC5Q",0,"MIT","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fevm-token-decimals\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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.\norigin: ECC direct-port adaptation\nversion: \"1.0.0\"\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,"origin":24,"version":25,"description":7},"ECC direct-port adaptation","1.0.0","master","877653a671c51fae6476bd9f0d34ee6c408d68b9",".github\u002Fskills\u002Fevm-token-decimals","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group","https:\u002F\u002Ftrivoxa-group.vercel.app","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web","2026-08-01 17:29:31",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add princepatel04477-web\u002Ftrivoxa-group --skill evm-token-decimals",{"tool":39,"command":40},"bunx","bunx skills add princepatel04477-web\u002Ftrivoxa-group --skill evm-token-decimals",{"tool":42,"command":43},"pnpm","pnpm dlx skills add princepatel04477-web\u002Ftrivoxa-group --skill evm-token-decimals","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\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},"01M78G4Z5RFJ72G536XYPC77PG","zustand-store-ts","Create Zustand stores following established patterns with proper TypeScript types and middleware.","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fzustand-store-ts\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},"01M78G4WQMHRST36KDP7AV3NR3","zoom-automation","Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fzoom-automation\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},"01M78G4T37F4SPS7M4KT0A8JJB","zoho-crm-automation","Automate Zoho CRM tasks via Rube MCP (Composio): create\u002Fupdate records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fzoho-crm-automation\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},"01M78G4QAJMF71KD1G38MNDQYK","zod-validation-expert","Expert in Zod — TypeScript-first schema validation. Covers parsing, custom errors, refinements, type inference, and integration with React Hook Form, Next.js, and tRPC.","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fzod-validation-expert\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},"01M78G4MS3WE96MH5P561KFY95","zipai-optimizer","Adaptive token optimizer: intelligent filtering, surgical output, ambiguity-first, context-window-aware, VCS-aware, MCP-aware.","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fzipai-optimizer\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},"01M78G4GZ0T47C6929V9CVH1AK","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fprincepatel04477-web\u002Ftrivoxa-group\u002Fblob\u002Fmaster\u002F.github\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[]]