kevinpurwito/laravel-web3-login 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kevinpurwito/laravel-web3-login

Composer 安装命令:

composer require kevinpurwito/laravel-web3-login

包简介

Allow your users to login with their Web3 wallets

README 文档

README

Code Style Psalm Latest Version on Packagist Total Downloads

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

This package is forked from the m1guelpf/laravel-web3-login with some modifications.

Installation

You can install the package via composer:

composer require kevinpurwito/laravel-web3-login

Configuration

The vendor:publish command will publish a file named web3.php within your laravel project config folder config/web3.php. Edit this file with your desired column name for the table, defaults to wallet.

Published Config File Contents

[
    'wallet_address_column' => env('WEB3_WALLET_ADDRESS_COLUMN', 'address'),
];

Alternatively you can ignore the above publish command and add this following variables to your .env file.

WEB3_WALLET_ADDRESS_COLUMN=wallet

Usage

This package takes care of everything you need on the backend. While there are many 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 log in, or by adding the option to their settings page.

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.

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),
	});
};

Changelog

Please see CHANGELOG for more information what has changed recently.

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.

kevinpurwito/laravel-web3-login 适用场景与选型建议

kevinpurwito/laravel-web3-login 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 145 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「web3」 「laravel-web3-login」 「kevinpurwito」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kevinpurwito/laravel-web3-login 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kevinpurwito/laravel-web3-login 我们能提供哪些服务?
定制开发 / 二次开发

基于 kevinpurwito/laravel-web3-login 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 145
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-12