UNPKG

@lighthouse-web3/sdk

Version:

NPM package and CLI tool to interact with lighthouse protocol

20 lines (19 loc) 778 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* istanbul ignore file */ const ethers_1 = require("ethers"); const lighthouse_config_1 = require("../../../lighthouse.config"); exports.default = async () => { try { //@ts-ignore const provider = new ethers_1.ethers.BrowserProvider(window.ethereum); const signer = await provider.getSigner(); const response = await fetch(`${lighthouse_config_1.lighthouseConfig.lighthouseAPI}/api/auth/get_message?publicKey=${signer.address}`); const message = (await response.json()); const signature = await signer.signMessage(message); return `${signer.address}$${signature}`; } catch (error) { throw new Error(error.message); } };