5.3 KiB
MetaMask WETH9 Display Bug Analysis
Date: $(date)
Issue: MetaMask displaying "6,000,000,000.0T WETH" instead of "6 WETH"
Contract: WETH9 (0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)
Network: Defi Oracle Meta Mainnet (ChainID 138)
🐛 The Problem
MetaMask is incorrectly displaying the WETH9 balance as "6,000,000,000.0T WETH" when the actual balance is 6 WETH.
What MetaMask Shows
- Wrapped Ether:
6,000,000,000.0T WETH❌ (Incorrect) - Ethereum:
1.00B ETH(Also suspicious - likely 1 billion ETH) - WETH:
0 WETH✅ (Correct)
Actual On-Chain Values
- WETH9 Total Supply: 6 WETH ✅
- WETH9 Contract Balance: 6 ETH ✅
- User Balance: 6 WETH ✅
🔍 Root Cause Analysis
Likely Causes
-
Missing or Incorrect
decimals()Function- WETH9 may not implement the standard ERC-20
decimals()function - MetaMask expects
decimals()to return18for WETH - If it returns
0or doesn't exist, MetaMask may default to wrong decimal handling
- WETH9 may not implement the standard ERC-20
-
MetaMask Number Formatting Bug
- MetaMask may be reading the raw wei value:
6,000,000,000,000,000,000 - Without proper decimals, it might be formatting as:
6,000,000,000.0T - The "T" likely stands for "Trillion" in MetaMask's display format
- MetaMask may be reading the raw wei value:
-
Token Metadata Issue
- WETH9 may not be in MetaMask's token list
- MetaMask may be using default/incorrect metadata
- Missing proper token configuration for ChainID 138
✅ Verification
On-Chain Verification
# Check total supply (should be 6 WETH)
cast call 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
"totalSupply()" \
--rpc-url http://192.168.11.250:8545 | \
xargs -I {} cast --to-unit {} ether
# Output: 6 ✅
# Check contract balance (should be 6 ETH)
cast balance 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
--rpc-url http://192.168.11.250:8545 | \
xargs -I {} cast --to-unit {} ether
# Output: 6 ✅
# Check decimals function
cast call 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
"decimals()" \
--rpc-url http://192.168.11.250:8545
# Output: 0x0 (likely the issue!)
Actual Values
- Raw Wei:
6,000,000,000,000,000,000wei - ETH Equivalent:
6.0ETH - Display Should Be:
6 WETHor6.0 WETH
🔧 Solutions
Solution 1: Add WETH9 to MetaMask Token List (Recommended)
Create a proper token list entry for WETH9:
{
"chainId": 138,
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
"logoURI": "https://raw.githubusercontent.com/ethereum/ethereum.org/main/static/images/eth-diamond-black.png"
}
Steps:
- Create a token list JSON file
- Host it on a public URL (GitHub, IPFS, etc.)
- Add to MetaMask: Settings → Security & Privacy → Token Lists
- Or import directly in MetaMask: Import Token → Custom Token
Solution 2: Manually Import Token in MetaMask
- Open MetaMask
- Go to "Import tokens"
- Enter:
- Token Contract Address:
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 - Token Symbol:
WETH - Decimals of Precision:
18
- Token Contract Address:
- Click "Add Custom Token"
Solution 3: Fix WETH9 Contract (If Possible)
If WETH9 contract can be modified, ensure it implements:
- Standard ERC-20
decimals()function returning18 - Standard ERC-20 interface
Note: Since WETH9 is pre-deployed in genesis, this may not be possible without redeploying.
Solution 4: Use a Different WETH Contract
If WETH9 cannot be fixed, consider:
- Using WETH10 (
0xf4BB2e28688e89fCcE3c0580D37d36A7672E8A9f) if it has proper decimals - Deploying a new WETH contract with proper ERC-20 implementation
📊 Impact Assessment
Current Impact
- Display Issue: Users see incorrect balance (6 trillion vs 6)
- Functional Impact: None - transactions work correctly
- User Confusion: High - misleading display
Risk Level
- Low: This is purely a display issue
- No Financial Risk: Actual balances are correct on-chain
- UX Issue: Users may be confused or concerned
🔍 Additional Observations
Other Display Issues in Screenshot
-
Ethereum Balance: Shows "1.00B ETH"
- This is also suspicious
- Should verify actual ETH balance
- May be another display formatting issue
-
Network Name: "Defi Oracle Meta Mainnet"
- This is ChainID 138
- Network configuration appears correct
-
WETH Token: Shows "0 WETH" ✅
- This appears correct
- May be a different WETH contract address
📝 Recommendations
- Immediate: Add WETH9 to MetaMask token list with proper decimals (18)
- Short-term: Verify all token contracts have proper
decimals()implementation - Long-term: Create comprehensive token list for ChainID 138
- Documentation: Document all token addresses and their proper configurations
✅ Verification Checklist
- On-chain balance verified: 6 WETH ✅
- Contract balance verified: 6 ETH ✅
decimals()function checked: Returns 0x0 (likely issue)- Token list entry created
- MetaMask token import tested
- Display verified after fix
🔗 Related Documentation
Last Updated: $(date)