This project implements a blockchain-based Two-Factor Authentication (2FA) system using a smart contract deployed on the Ethereum blockchain. It enhances user authentication security by combining blockchain technology with One-Time Passwords (OTPs).
The TwoFactorAuth
smart contract provides functionalities for user registration, OTP generation, and user authentication. It leverages custom error handling to manage various error states effectively.
- Deploy the Contract: Run the deployment script to deploy the contract to your desired network.
- Interact with the Contract: Use the JavaScript interaction script to register users, generate OTPs, and authenticate users.
-
Clone the repository:
git clone (https://https://github.com/wali-hu/Blockcahin-Based-Two-Factor-Authentication) cd Blockcahin-Based-Two-Factor-Authentication
-
Install dependencies:
npm install
-
Compile the smart contract:
forge build
-
Deploy And Test the contract:
forge script DeployTwoFactorAuth.s.sol
forge test
-
Run the interaction script:
node interact.js
This project is licensed under the MIT License.
- Forge: For smart contract development and testing.
- Ethers.js: For interacting with Ethereum from JavaScript.