I've updated the Web3 connection code to provide better error handling and user feedback when connecting to MetaMask.
- β Better error messages with user-friendly alerts
- β MetaMask installation check
- β Success confirmation when connected
- β TypeScript type definitions for window.ethereum
- β Helpful tips for demo mode usage
-
Go to MetaMask website:
- Visit: https://metamask.io/
-
Click "Download"
- Choose your browser (Chrome, Firefox, Brave, Edge)
-
Install the extension
- Click "Add to Chrome" (or your browser)
- Click "Add Extension"
-
Set up your wallet
- Click "Get Started"
- Choose "Create a new wallet"
- Create a password
- IMPORTANT: Save your Secret Recovery Phrase securely!
-
Refresh your browser
- Go to
http://localhost:3000
- Go to
-
Click "Connect Wallet"
- The green button in the top right
-
Approve in MetaMask
- MetaMask popup will appear
- Click "Next"
- Click "Connect"
-
Success!
- You'll see your wallet address in the navigation
- Format:
0x1234...5678
You can use TruthChain without MetaMask! Just navigate directly to the pages:
-
Creator Portal:
http://localhost:3000/creator- Register with username/password
- No wallet needed!
-
Admin Panel:
http://localhost:3000/admin- Approve creators
- Manage content
- No wallet needed!
-
Explore Page:
http://localhost:3000/explore- Browse all content
- Search and filter
- No wallet needed!
-
Verify Page:
http://localhost:3000/verify- Verify content by hash, text, file, or creator
- No wallet needed!
Solution:
- Install MetaMask from https://metamask.io/
- Refresh the page
- Click "Connect Wallet" again
OR use demo mode (see Option 2 above)
Cause: You clicked "Reject" in the MetaMask popup
Solution:
- Click "Connect Wallet" again
- This time, click "Connect" in MetaMask popup
Cause: MetaMask popup is already open
Solution:
- Look for the MetaMask icon in your browser toolbar
- Click it to open the pending request
- Approve or reject the connection
Solution:
-
Check if MetaMask is unlocked:
- Click the MetaMask icon
- Enter your password if locked
-
Check browser console:
- Press F12
- Look for error messages
- Share them if you need help
-
Try refreshing:
- Refresh the page
- Try connecting again
- TruthChain requests access to your MetaMask wallet
- MetaMask shows a popup asking for permission
- You approve the connection
- TruthChain receives your wallet address
- Your address is displayed in the navigation bar
β Can:
- Read your wallet address
- Request you to sign transactions
- Display your address in the UI
β Cannot:
- Access your funds without permission
- Make transactions without your approval
- See your private keys
TruthChain is configured to use Polygon Amoy Testnet for testing.
Network Details:
- Chain ID: 80002 (0x13882)
- RPC URL: https://rpc-amoy.polygon.technology
- Currency: MATIC (testnet)
- Explorer: https://amoy.polygonscan.com/
- Connect your wallet to TruthChain
- MetaMask will prompt to add the network
- Click "Approve" to add Polygon Amoy
- Switch to the network if not automatic
OR manually add:
- Open MetaMask
- Click the network dropdown (top center)
- Click "Add Network"
- Click "Add a network manually"
- Enter:
- Network Name:
Polygon Amoy Testnet - RPC URL:
https://rpc-amoy.polygon.technology - Chain ID:
80002 - Currency Symbol:
MATIC - Block Explorer:
https://amoy.polygonscan.com/
- Network Name:
- Click "Save"
To use TruthChain on the blockchain, you'll need testnet MATIC (it's free!):
- Connect MetaMask to TruthChain
- Copy your address (click the address to copy)
- Go to: https://faucet.polygon.technology/
- Select "Polygon Amoy"
- Paste your wallet address
- Click "Submit"
- Wait 1-2 minutes
- Check MetaMask
- You should see testnet MATIC balance
-
Your address is displayed in the navigation
- Format:
0x1234...5678 - Green dot indicates connected
- Format:
-
You can disconnect anytime
- Click the logout icon next to your address
-
Creator Portal will use your wallet address
- Register as a creator
- Your wallet address is your identity
-
Content Upload will be linked to your wallet
- All content you upload is associated with your address
Visual Indicators:
- β Green "Connect Wallet" button β Not connected
- β Your address displayed β Connected
- β Green dot next to address β Active connection
In Console (F12):
// Check if MetaMask is installed
console.log('MetaMask installed:', typeof window.ethereum !== 'undefined');
// Check current account
window.ethereum?.request({ method: 'eth_accounts' })
.then(accounts => console.log('Connected accounts:', accounts));-
Open TruthChain:
http://localhost:3000 -
Click "Connect Wallet"
-
You should see:
- MetaMask popup appears
- OR alert saying "MetaMask is not installed"
-
If MetaMask popup appears:
- Click "Connect"
- See success alert
- See your address in navigation
-
If alert appears:
- Follow installation steps above
- OR use demo mode
-
Never share your Secret Recovery Phrase
- MetaMask will NEVER ask for it
- TruthChain will NEVER ask for it
- Anyone with it can steal your funds
-
Always verify the website
- Make sure you're on
localhost:3000(development) - Check the URL before connecting
- Make sure you're on
-
Review transactions before signing
- MetaMask will show transaction details
- Read them carefully before approving
-
Use testnet for testing
- Polygon Amoy is a testnet
- Testnet MATIC has no real value
- Perfect for learning and testing
- β Full blockchain integration
- β Real wallet addresses
- β Transaction signing
- β Decentralized identity
- β Production-ready features
- β All features work
- β LocalStorage instead of blockchain
- β Username/password auth
- β Perfect for testing
- β No installation needed
-
Is MetaMask installed?
- Look for the fox icon in your browser toolbar
- If not, install from https://metamask.io/
-
Is MetaMask unlocked?
- Click the MetaMask icon
- Enter your password if needed
-
Is the popup blocked?
- Check your browser's popup blocker
- Allow popups for localhost
-
Browser console errors?
- Press F12
- Check the Console tab
- Look for red error messages
-
Try incognito mode:
- Open an incognito/private window
- Install MetaMask there
- Try connecting
- MetaMask Support: https://support.metamask.io/
- Polygon Docs: https://docs.polygon.technology/
- TruthChain Docs: See TROUBLESHOOTING.md
π You're all set! Connect MetaMask and start using TruthChain! π¦
Last Updated: 2025-11-29
For TruthChain v1.0