web3-auth-middleware
v1.0.1
Published
A JavaScript package for authenticating users using Web3 wallets.
Downloads
4
Readme
Web3 Authentication Middleware
A JavaScript package for authenticating users using Web3 wallets.
Installation
npm install web3-auth-middleware
Usage
const Web3AuthMiddleware = require('web3-auth-middleware');
const Web3 = require('web3');
// Initialize Web3 with the provider of your choice
const web3Provider = 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID';
const web3 = new Web3(web3Provider);
// Create a new instance of the Web3 Authentication Middleware
const authMiddleware = new Web3AuthMiddleware(web3);
// Authenticate the user
authMiddleware.authenticate()
.then((authenticatedUser) => {
console.log('Authenticated user:', authenticatedUser);
// Proceed with authenticated user
})
.catch((error) => {
console.error('Authentication failed:', error);
// Handle authentication failure
});
API
authenticate()
Authenticates the user using Web3 wallets.
Returns a promise that resolves to the authenticated user's Ethereum address.
License
This project is licensed under the MIT License - see the LICENSE file for details.