UNPKG

@lighthouse-web3/sdk

Version:

NPM package and CLI tool to interact with lighthouse protocol

21 lines (20 loc) 797 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 (privateKey) => { try { if (!privateKey) { throw new Error('Private key not provided!!!'); } const signer = new ethers_1.ethers.Wallet(privateKey); 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); } };