Welcome to Day 1 of the tutorial! Today we'll set up a Chrome extension development environment using Javascript and MetaMask integration. We'll be working with a proven boilerplate and setting up our local blockchain development tools.
We're using the chrome-extension-react-metamask-boilerplate - a starter template that provides:
- Chrome extension structure with React
- Web3 integration for blockchain interaction
- MetaMask wallet login support
- Gulp-based build system for extension development
- CSS Modules support
- ESLint configuration
Repository: https://github.com/shaheem-khanzada/chrome-extension-react-metamask-boilerplate
Make sure you have the following installed on your system:
- Node.js (v14 or higher)
- npm (comes with Node.js)
- Git
- Chrome/Chromium browser (for testing the extension)
Navigate to the project directory and install all required npm packages:
npm installThis will install all dependencies listed in package.json, including:
- React and React DOM
- Web3.js for blockchain interaction
- Gulp for build automation
- ESLint for code quality
- And other necessary packages
Wait for the installation to complete. You should see a node_modules folder created in your project directory.
Truffle is a development framework for Ethereum that allows us to write, compile, and deploy smart contracts.
Install Truffle globally:
npm install -g truffleVerify the installation:
truffle versionYou should see version information displayed.
Ganache is a personal blockchain emulator for Ethereum development. It allows us to test our smart contracts and dApps locally without spending real Ether.
npm install -g ganache-cliVerify the installation:
ganache-cli --versionAlternatively, you can download the GUI version from: https://trufflesuite.com/ganache/
ganache-cliGanache will start on http://127.0.0.1:8545 by default and display:
- 10 test accounts with private keys
- Contract deployment address
- Network ID
Keep this terminal running - this is your local blockchain.
In a new terminal, start the development build:
npm startThis will:
- Watch for file changes in the
src/directory - Compile React and bundle the extension
- Output the built files to the
dist/folder - Display the build process in your terminal
- Open Chrome and navigate to:
chrome://extensions/ - Enable Developer mode (toggle in the top-right corner)
- Click Load unpacked
- Navigate to your project's
dist/folder and select it - The extension should now appear in your extensions list and in the Chrome toolbar
├── src/ # React source code
│ ├── App.js # Main React component
│ ├── App.css
│ ├── index.js # Entry point
│ ├── context/
│ │ └── WalletProvider.js # Web3/MetaMask wallet context
│ └── utils/
│ ├── events.js # Event handling utilities
│ ├── storage.js # Local storage utilities
│ └── index.js
├── public/ # Static files
│ ├── index.html
│ ├── manifest.json # Chrome extension configuration
│ └── robots.txt
├── dist/ # Built extension (generated after npm start)
├── patches/ # npm patches
├── gulpfile.js # Gulp build configuration
├── package.json # Project dependencies
└── manifest.json # Extension manifest
- manifest.json - Defines your extension's metadata, permissions, and content scripts
- src/App.js - Your main React application component
- src/context/WalletProvider.js - Web3 and MetaMask integration
- gulpfile.js - Build automation tasks
# Start development build with file watching
npm start
# Build for production
npm run build
# Run tests (if configured)
npm test# Start local blockchain
ganache-cli
# Compile smart contracts
truffle compile
# Deploy smart contracts to local blockchain
truffle migrate
# Run truffle console connected to local blockchain
truffle console
# Stop Ganache (Ctrl + C in its terminal)
# Stop npm start (Ctrl + C in its terminal)- ✓ Cloned and configured chrome-extension-react-metamask-boilerplate
- ✓ Installed all npm dependencies
- ✓ Configured Truffle and Ganache for local blockchain development
- ✓ Set up project structure with contracts, migrations, and tests folders
- ✓ Created
VaultRegistry.sol- Solidity smart contract with three core functions:updateVaultHash(bytes32 _vaultHash)- Store encrypted vault hash on blockchaingetVaultHash(address user)- Retrieve vault hash for verificationverifyVault(address user, bytes32 localHash)- Verify vault integrity
- ✓ Deployed contract migration script (
2_deploy_contract.js)
Created and configured essential React components:
-
Login.js - Authentication screen with:
- Master password creation/unlock functionality
- Password strength indicator
- Toast notifications for user feedback
- Integration with Web3 for vault verification
- Blockchain integrity checks
-
Vault.js - Main vault management interface featuring:
- Blockchain status display with wallet connection info
- Real-time vault hash verification
- Vault integrity confirmation
- Pending login alerts
- Encrypted storage management
- Search and filter capabilities
- Auto-fill functionality
-
Toast.js - Notification system with:
- Multiple notification types (error, success, warning, info)
- Gradient styling and glow effects
- Smooth animations
-
CryptoService.js - Encryption/decryption with:
- PBKDF2 key derivation (200,000 iterations)
- AES-256-GCM encryption
- Salt and IV generation
- Secure vault encryption
-
web3Service.js - Blockchain integration featuring:
- MetaMask provider initialization
- Smart contract interaction
- Vault hash computation
- Address management
- Contract read/write operations
-
storage.js - Chrome extension storage utilities:
- Save/load encrypted vault
- Chrome storage API compatibility
- ✓ Truffle configuration (
truffle-config.js) - ✓ Updated
package.jsonwith ethers.js dependency - ✓ Created directory structure (contracts/, migrations/, test/, src/components/, src/utils/)
- Frontend: React 18, CSS-in-JS styling
- Blockchain: Solidity 0.8.20, Ethereum
- Encryption: Web Crypto API (PBKDF2 + AES-GCM)
- Web3: ethers.js, MetaMask
- Development: Ganache CLI, Truffle Suite
- Build: Gulp, Browserify
- Encrypted Vault Storage - Master password-protected credential storage
- Blockchain Verification - On-chain hash verification for vault integrity
- MetaMask Integration - Wallet connection and signing
- Real-time Status Display - Blockchain sync status and verification state
- User Authentication - Create new vault or unlock existing vault
- Responsive UI - Dark theme with gradient effects and animations
Total Files Created/Modified: 15+
Lines of Code: 5000+
Components: 3 React components
Smart Contracts: 1 Solidity contract
Utility Services: 3 services
Configuration Files: Updated
With everything installed and running:
- Explore the boilerplate code in the
src/directory - Review the extension manifest in
public/manifest.json - Understand how Web3 is initialized in
src/utils/web3Service.js - Test the extension in Chrome and connect MetaMask
- Deploy VaultRegistry contract to Ganache
- Test vault creation and blockchain verification
- Clear npm cache:
npm cache clean --force - Delete
node_modulesandpackage-lock.json, then retry - Ensure Node.js version is v14 or higher
- Check if port 8545 is already in use
- Try:
ganache-cli -p 8546to use a different port
- Ensure you're loading the
dist/folder, not the project root - Verify
npm startcompleted successfully - Check Chrome DevTools (F12) for errors
- Reload the extension after making changes
- Ensure MetaMask browser extension is installed
- Check that Ganache is running on the correct port
- Verify network is set to
localhost:8545in MetaMask
- Chrome Extension Documentation
- Truffle Suite Documentation
- Ganache Documentation
- Web3.js Documentation
- MetaMask Developer Docs
Day 1 Implementation: Complete setup of encrypted password vault with on-chain integrity verification
FEATURES:
- Smart Contract: Deploy VaultRegistry with updateVaultHash, getVaultHash, and verifyVault functions
- Authentication: Master password-based vault creation and unlocking with strength validation
- Encryption: AES-256-GCM encrypted vault storage with PBKDF2 key derivation
- Blockchain Integration: Real-time vault hash verification on Ethereum via Ganache
- UI Components: Login, Vault management, and Toast notification system
- Web3 Integration: MetaMask provider integration with ethers.js
- Chrome Extension: Configured popup extension with React and Gulp build system
COMPONENTS ADDED:
- src/components/Login.js (350+ lines) - Authentication with blockchain verification
- src/components/Vault.js (450+ lines) - Vault display with blockchain status
- src/components/Toast.js (280+ lines) - Toast notification system
- src/utils/CryptoService.js (80+ lines) - Encryption/decryption utilities
- src/utils/web3Service.js (150+ lines) - Web3 and smart contract integration
- src/utils/storage.js (30+ lines) - Chrome storage utilities
- contracts/VaultRegistry.sol (40+ lines) - Smart contract for vault integrity
- migrations/2_deploy_contract.js - Contract deployment script
CONFIGURATION:
- Updated package.json with ethers library
- Created truffle-config.js for Ganache integration
- Established project structure for contracts and migrations
IMPROVEMENTS:
- End-to-end encrypted credential management
- Immutable vault integrity checks via blockchain
- Real-time wallet and verification status display
- Enhanced security with PBKDF2 (200k iterations) + AES-256
- User-friendly error handling with styled notifications
BREAKING CHANGES: None
TESTING:
- Manual testing with Ganache local blockchain
- MetaMask wallet connection verification
- Vault creation and encryption validation
- Blockchain hash verification
- Files Changed: 15+
- Total Lines Added: ~5,000
- New Components: 3 (Login, Vault, Toast)
- New Services: 3 (CryptoService, web3Service, storage)
- Smart Contracts: 1 (VaultRegistry.sol)
- Build Configuration: 2 (truffle-config.js, package.json)
- package.json - Added ethers dependency
- src/App.js - Updated main component with vault logic flow
- src/App.css - Refreshed styling for modern dark theme
- New Directories - contracts/, migrations/, src/components/, src/utils/
#day1 #blockchain #encryption #ethereum #metamask #chrome-extension #vault #security
Author: Guardium Security Team Date: December 19, 2025 Status: Development Phase 1 Complete
Ready for Day 1? You now have a complete development environment for building Chrome extensions with blockchain functionality!