๐Ÿ”‘Create an API Key

An API key is required to use Lighthouse, it can be generated using Files Dapp UI (check quick start for more detail), CLI, and SDK. Refer to the given code examples to generate an API key based on your preferred environment.

In general, to create an API key there are two steps involved: 1. The user requests an authentication message from the message API. 2. The user signs the auth message to get the API key.

import axios from 'axios'
import { ethers } from 'ethers'
import lighthouse from '@lighthouse-web3/sdk'

const signAuthMessage = async(privateKey, verificationMessage) =>{
  const signer = new ethers.Wallet(privateKey)
  const signedMessage = await signer.signMessage(verificationMessage)

const getApiKey = async() =>{
  const wallet = {
    publicKey: 'YOUR_PUBLIC_KEY', // Ex: '0xEaF4E24ffC1A2f53c07839a74966A6611b8Cb8A1'
    privateKey: 'WALLET_PRIVATE_KEY'
  const verificationMessage = (
    await axios.get(
  const signedMessage = await signAuthMessage(wallet.privateKey, verificationMessage)
  const response = await lighthouse.getApiKey(wallet.publicKey, signedMessage)


Last updated