小狐狸验证签名demo
<div @click="login()">
<div >验证签名</div>
</div>
import metamaskApi from "../service/web3/metamaskApi";//可以看 https://www.sky12580.cn/archives/metamask-lian-jie
import WalletConnect from "@walletconnect/node";
import QRCodeModal from "@walletconnect/qrcode-modal";
import utils from "web3-utils";
import abi from "web3-eth-abi";
import Web3 from "web3";
import keccak256 from "keccak256";
methods: {
login() {
console.log("地址:",sessionStorage.getItem("address"))
// Draft Message Parameters
const message = new Date().getTime();
console.log("时间戳:",message);
if (typeof web3 !== "undefined") {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org'));
}
let data = utils.utf8ToHex(message.toString());
console.log("sss2222s,",data)
let address=sessionStorage.getItem("address").toString()
web3.personal.sign(
data,
address,
(err, result) => {
if (!err) {
console.log(result)
} else {
// that.$message(result);
console.log(result)
}
}
);
},
}
展示效果