定制 desnake/web3signature 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

desnake/web3signature

Composer 安装命令:

composer require desnake/web3signature

包简介

Laravel package for extracting addresses from signed messages received from web3 client.

README 文档

README

Laravel Package for extracting addresses from web3 signed messages

Usage

Composer:

composer require desnake/web3signature

In view:

//prepare message to sign

const msgtext = {{$msg}};   //Message from backend database sent with view
const hashedMessage = Web3.utils.fromUtf8(msgtext);
console.log(hashedMessage);

//get user to sign the message

const signature = await window.web3.eth.sign(hashedMessage, accounts[0]);

//Make request to controller and verify signature in backend via API
//!!CAUTION!!
//Not much secure way to do this but only for demo purposes.

const URL = "api.myproject.com/api/v1/";
const request = URL + msgtext + "/" + signature;

window.location.href(request);

In controller:

1: Make a api route in such a way that a signature is passed to controller function 2: Import trait Web3ForContracts into the controller:

    use DeSnake\Web3signature\Web3ForContracts;
    and Include trait into the controller class.
    `` use Web3ForContracts;``

3: Call personal_ecRecover function from controller:

Note: $msg is plaintext string that is signed and signature is the signed message
    $msg = "Hello World";   //Message from backend database.
    $address = $this->personal_ecRecover($msg, $signature);

NOTE:

Package is in development mode.

Full examples are available in ./Example folder.

Special Thanks to https://github.com/wmh/php-ecrecover && https://github.com/Wekisen/php-ecrecover && https://github.com/simplito/elliptic-php

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2022-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固