A secure, decentralized authentication system built with JavaScript, React, and Ethereum blockchain. This project demonstrates modern blockchain-based login, credential management, and user experience best practices.
- Decentralized Login: Authenticate with your Ethereum wallet (MetaMask, WalletConnect, etc.)
- Secure Credentials: User credentials are stored immutably on the blockchain
- Smart Contracts: Ethereum smart contracts manage registration and authentication
- Token-Based Authentication: JWT tokens for secure API access
- User Registration: Register your Ethereum address and username
- Activity Logging: All authentication attempts and transactions are logged on-chain
- Multi-Factor Authentication: Extendable for MFA (e.g., Google Authenticator)
- Cross-Platform Support: Works on all modern browsers and devices
- Modern UI/UX: Responsive, accessible, and beautiful interface with Tailwind CSS
- Frontend: React.js, Tailwind CSS
- Blockchain: Ethereum, Solidity, Hardhat
- Web3 Libraries: ethers.js, web3.js, web3modal
- Backend/Server: Node.js, Express (for API/JWT if needed)
- Authentication: JWT (JSON Web Token)
- Testing: Hardhat, Mocha/Chai
- Node.js (v16+ recommended)
- npm or yarn
- MetaMask or any Ethereum wallet
- Infura or Alchemy API key (for testnet/mainnet deployment)
git clone https://github.com/SNO7E-G/blockchain-based-authentication.git
cd blockchain-based-authentication
npm installCreate a .env file in the root directory:
PRIVATE_KEY=your_ethereum_private_key_here
INFURA_API_KEY=your_infura_api_key_here
JWT_SECRET=your_jwt_secret_herenpx hardhat compile
npx hardhat node # In a separate terminal for local blockchain
npx hardhat run scripts/deploy.js --network localhostnpm start- Register: Go to
/register, enter a username, connect your wallet, and sign the message. - Login: Go to
/login, connect your wallet, and sign the authentication message. - Dashboard: View your blockchain-based profile, authentication history, and manage your account.
- Solidity contract:
src/contracts/AuthenticationContract.sol - Interact using Hardhat console:
npx hardhat console --network localhost
npx hardhat test- Goerli Testnet:
npx hardhat run scripts/deploy.js --network goerli
- Ethereum Mainnet:
npx hardhat run scripts/deploy.js --network mainnet
- Never commit private keys to version control
- Use
.envfor all secrets and sensitive data - All authentication is signature-based (no passwords transmitted)
- Smart contract code is open and auditable
- Consider gas costs and rate limiting for production
Contributions, issues, and feature requests are welcome!
- Fork the repo
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
Author: Mahmoud Ashraf (SNO7E)
GitHub: https://github.com/SNO7E-G
License: MIT
© 2024 Mahmoud Ashraf (SNO7E). All rights reserved.
"Empowering secure, decentralized identity for the next generation of web applications."