Skip to main content
Version: v2.x.x

Setup the Project

Smart Contract

  1. Install hardhat:
yarn add hardhat
  1. Init hardhat to create the boilerplate for a Basic project (with Javascript):
npx hardhat init
  1. Install Openzepplin:
yarn add @openzeppelin/contracts
  1. Test deploy the sample smart contract on 2 separate terminals:
npx hardhat node
npx hardhat run scripts/deploy.js --network localhost

Now that we have our hardhat working & the sample smart contract is deployed correctly, let's setup our Lit SDK, which we will use to encrypt & decrypt the metadata.


You can use the Lit JS SDK V2 to encrypt and store any static content. This could be a file, a string, or anything that won't change (we're going to encrypt an input string). You have to store the content and metadata yourself (we're storing that on a blockchain network), but Lit will store who is allowed to decrypt it and enforce this (aka key management).

  1. Install Lit JS SDK V2:
yarn add @lit-protocol/lit-node-client
  1. Create a Lit class which will have all the encryption & decryption functions we require:
import * as LitJsSdk from "@lit-protocol/lit-node-client";

const client = new LitJsSdk.LitNodeClient();

class Lit {

async connect() {
await client.connect();
this.litNodeClient = client;

client.connect() will return a promise that resolves when you are connected to the Lit Network. You may also listen for the lit-ready event.

In this code example, the litNodeClient is set as a global variable for use throughout the web app.