Allow your users to login with their Ethereum wallet.

Overview

Allow your users to login with their Ethereum wallet

Latest Version on Packagist Total Downloads

Allow your users to link their Ethereum wallet to their account to skip entering their login credentials.

Installation

You can install the package via composer:

composer require m1guelpf/laravel-web3-login

Usage

This package takes care of everything you need on the backend. While there are many different ways of asking the user to sign a message with their wallet, we'll be using web3modal and ethers to maximize the support for wallet providers.

To get started, you need to have the user register a new credential. You can do so by presenting them with a modal when they login, or by adding the option to their settings page.

{ const message = await axios.get("/_web3/signature").then((res) => res.data); const provider = await web3Modal.connect(); provider.on("accountsChanged", () => web3Modal.clearCachedProvider()); const web3 = new ethers.providers.Web3Provider(provider); axios.post("/_web3/link", { address: await web3.getSigner().getAddress(), signature: await web3.getSigner().signMessage(message), }); }; ">
import axios from "axios";
import { ethers } from "ethers";
import Web3Modal from "web3modal";

const web3Modal = new Web3Modal({
	cacheProvider: true,
	providerOptions: {}, // add additional providers here, like WalletConnect, Coinbase Wallet, etc.
});

const onClick = async () => {
	const message = await axios.get("/_web3/signature").then((res) => res.data);
	const provider = await web3Modal.connect();

	provider.on("accountsChanged", () => web3Modal.clearCachedProvider());

	const web3 = new ethers.providers.Web3Provider(provider);

	axios.post("/_web3/link", {
		address: await web3.getSigner().getAddress(),
		signature: await web3.getSigner().signMessage(message),
	});
};

Then, on the login page, you can provide an option to log in with their wallet.

{ const message = await axios.get("/_web3/signature").then((res) => res.data); const provider = await web3Modal.connect(); provider.on("accountsChanged", () => web3Modal.clearCachedProvider()); const web3 = new ethers.providers.Web3Provider(provider); axios.post("/_web3/login", { address: await web3.getSigner().getAddress(), signature: await web3.getSigner().signMessage(message), }); }; ">
import axios from "axios";
import { ethers } from "ethers";
import Web3Modal from "web3modal";

const web3Modal = new Web3Modal({
	cacheProvider: true,
	providerOptions: {}, // add additional providers here, like WalletConnect, Coinbase Wallet, etc.
});

const onClick = async () => {
	const message = await axios.get("/_web3/signature").then((res) => res.data);
	const provider = await web3Modal.connect();

	provider.on("accountsChanged", () => web3Modal.clearCachedProvider());

	const web3 = new ethers.providers.Web3Provider(provider);

	axios.post("/_web3/login", {
		address: await web3.getSigner().getAddress(),
		signature: await web3.getSigner().signMessage(message),
	});
};

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Iranian wallet provider's integration component for Laravel Framework

Iranian Wallets Integration Component For Laravel Iranian Wallet provider integration handler for Laravel 8.1+ known as LaraWallet component completel

A PocketMine-MP Plugin that allow you to change your nickname to specific colors
A PocketMine-MP Plugin that allow you to change your nickname to specific colors

General Home A PocketMine-MP Plugin that allow you to change your display nametag to specific colors Made By BabosApple And Updated To PM4 By ZhorifCr

❄️ Magento 2 Snowflake module allow you to add snow and even more on your site and make winter fun.

❄️ Magento 2 Snowflake module allow you to add snow and even more on your site and make winter fun.

Talkino allows you to integrate multi social messengers and contact into your website and enable your users to contact you using multi social messengers' accounts.

Talkino Welcome to our GitHub Repository Talkino is a click to chat plugin to show your agents’ multiple social messengers, phone and emails on the ch

Allow multiple options for Magento 2 checkout layout. Provides capabilities to AB test checkout changes and more.
Allow multiple options for Magento 2 checkout layout. Provides capabilities to AB test checkout changes and more.

Aimes_CheckoutDesigns Features Please note: This module is currently still considered a proof of concept. This module provides the ability to change c

Formcreator is a plugin which allow creation of custom forms of easy access
Formcreator is a plugin which allow creation of custom forms of easy access

Formcreator is a plugin which allow creation of custom forms of easy access. At the same time, the plugin allow the creation of one or more tickets when the form is filled.

Methods to allow the mapping of cases to snake / camel for input / output

Methods to allow the mapping of cases to snake / camel for input / output This is where your description should go. Limit it to a paragraph or two. Co

Allow players to see how well they are doing while pvping with the help of a combo counter

Combo-Counter Allow players to see how well they are doing while pvping with the help of a combo counter Settngs / Config #set to false if you dont wa

This plugin allow you play music from resources pack in minecraft

Music Player for PocketMine-MP Commands music-start songname music-stop songname IMPORTANT! You must add music resources pack to PocketMine resources

Releases(v1.0.1)
Owner
Miguel Piedrafita
19-year-old maker
Miguel Piedrafita
Silverstripe-masquerade - SilverStripe module to allow users to "masquerade" as other users

SilverStripe Masquerade Module About This module is designed to allow an Administrator to "login" as another "Member" without changing their password

Daniel Hensby 14 Apr 14, 2022
Allow any Discord user to sign in to your website and save their discord user information for later use.

Simple Discord SSO ( Single Sign-On ) Requires at least: 5.0 Tested up to: 5.8.3 Stable tag: 1.0.2 Requires PHP: 7.4 License: GPLv2 or later License U

null 2 Oct 7, 2022
A web application built on PHP for user to view their credit information in their mysql database

TheCreditInfo Table of Content About Inspiration Technologies Client Pages Usage About Credere is a website created to help you track your credit hist

Abdul-Baseet Shabi 0 Jul 21, 2022
A WordPress package to nudge users to upgrade their software versions (starting with PHP)

whip A WordPress package to nudge users to upgrade their software versions (starting with PHP) Requirements The following versions of PHP are supporte

Yoast 71 Oct 18, 2022
Reset UI Bookmarks allows admin users to reset their own UI bookmarks such as state of filters, column positions and applied sorting ( e.g Sales > Orders ).

Reset Ui Bookmarks Reset UI Bookmarks becomes an invaluable tool while working daily in the admin panel, especially on Magento® instances with a large

Magenizr 23 Oct 19, 2022
A simple laravel package for wallet implementation

wallet A simple laravel package for wallet implementation. This package can basically be plugged into a laravel project and it will handle wallet impl

Ademuyiwa Adetunji 8 Dec 1, 2022
> Create e-wallet, send money, withdraw and check balance all via USSD protocol

Mobile Money USSD solution Create e-wallet, send money, withdraw and check balance all via USSD protocol Create e-wallet Step 1 Step 2 Step 3 Step 4 S

Emmanuel HAKORIMANA 1 Nov 3, 2021
Set of classes and tools to communicate with a Noso wallet using NosoP

NosoPHP Set of classes and tools to communicate with a Noso wallet using NosoP(Noso Protocol) Examples Node Info include __DIR__ . '/vendor/autoload.p

Noso Project 1 Jan 10, 2022
ระบบโดเนท Truemoney Wallet แบบขึ้นจอ streamlabs

ระบบ Donate Truemoney Wallet ฟีเจอร์ โดเนทผ่านลองค์ของขวัญ Truemoney Wallet ขึ้นจอ Streamlabs แจ้งเตือนผ่าน Line Notify การใช้งาน โหลดไฟล์ แก้ไฟล์ con

null 6 Sep 22, 2022
Class PHP Api อั่งเปา True Wallet

Description: API อั่งเปา True Wallet (Rework) Features: ตรวจสอบอั่งเปา ใช้อั่งเปา แสดงผลออกมาเป็น Json Example: <?php use M4h45amu7x\Voucher; require

null 11 Oct 4, 2022