承接 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
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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