Lit Protocol Starter Guide

Everything you need to get started building with Lit.

Lit Protocol Starter Guide

At a hackathon or working on a personal project and interested in integrating Lit into your project? Here's a handy guide on how to integrate Lit with a few examples and tutorials:

Encryption and Access Control

Lit Protocol's main feature is a decentralized access control protocol compatible with most EVM chains, Cosmos and Solana. With Lit, you can harness on-chain access control conditions to do 4 main things:

  • Encrypt and lock static content (images, videos, music, etc) behind an on-chain condition (for example, ownership of an NFT).
  • Decrypt static content that was locked behind an on-chain condition.
  • Authorize network signatures that provide access to dynamic content (for example, a server or network resource) behind an on-chain condition.
  • Request a network signed JWT that provisions access and authorization to dynamic content behind an on-chain condition.

With this functionality, Lit Protocol enables the storage of private data on the open web, facilitating interoperability and portability between previously disconnected users, applications and ecosystems.

You can get started with encryption and access control here.

Decentralized Cloud Signing

Lit’s access control protocol gives individuals the ability to read private data from the dWeb based on on-chain conditions. But this is only one half of the equation. What about writing data?

To facilitate this second use case we created two things: Lit Actions and Programmable Key Pairs (PKPs). Lit Actions are immutable JavaScript functions stored on IPFS. Actions can be thought of as smart contracts with superpowers: they have network access and the ability to make arbitrary HTTP requests.

PKPs are the public/private key pairs generated by the Lit network and are minted in the form of an ERC-721 NFT. The owner of the NFT becomes the sole controller of the underlying private key.

When these components work together, they have the power to facilitate complex condition-based automation. What if you could “tell” your wallet to execute a trade when your token fell below a specified price? Or to automatically list your NFT when the collection hits a certain floor price? Or what if you wanted to use off-chain or cross-chain data as a “trigger” to execute functionality within your decentralized application? With Lit, these use cases become possible.

These tools can also be harnessed within the context of proof generation. Conditional-based signing through Lit Actions opens up the possibility of verifying data from arbitrary sources, such as an off-chain API or cross-chain application. Get started with proofs here.

Keep reading about PKPs and Lit Actions here.

Tutorials, Guides and Examples:

Encryption

Decentralized Unlockable Content

Content stored on the decentralized web is platformless and public. This introduces privacy concerns as we now have a fully accessible online world. Since this content is stored publicly, we need a way to keep information private. How do we keep publicly searchable content private? Through encryption! Check out this guide to create private, decentralized content with Lit Protocol.

Ceramic Integration

Store encrypted data on Ceramic using this integration and check out the corresponding example implementation of that integration here. You can use this tool to store private data in your decentralized applications.

Arweave x Bundlr

Read this guide on how to encrypt data using Lit Protocol, upload it to Arweave with Bundlr, fetch it, and decrypt using Lit.

NextJS: Token Gate a URL Page

This is a minimal example of how to token-gate a Next.js page within the getServerSideProps. This example was created by Nader Dabit.

Authorize Dynamic Content via JWT: Cloudflare x Lit Protocol

Use Lit to authorize access to dynamic content via JWT - even on centralized services like Cloudflare.

Lit x Cloudflare Code Template for URL Gating, GitHub Repo

Lit Documentation to Authorize Dynamic Content via JWT

Encryption and Private Data Using Lit

Check out this video that explains how to add encryption and private data using Lit Protocol. This video was created by Lit’s CTO and co-founder, Chris Cassano.

Lit Actions + Programmable Key Pairs (PKPs)

Ceramic Signer

This package can be used to sign Ceramic transactions with a PKP using Lit Actions.

Example Application

You can find an example implementation (a React app) of talking to Ceramic and signing with Lit Actions / PKPs here.

Sling Protocol

An SDK for automating DEX interactions using PKPs and Lit Actions. Example functionality includes frictionless swaps with signature abstraction and on-chain limit orders. This project was funded by our Grants program.

Conditional Signing

Conditionally signed response using Lit Actions. Displays the returned JSON if Ether balance >= Min balance entered AND if you signed the transaction within 2 mins of the set time.

Here you can find the complete React project.

Weather API Signing

Signed Response from Weather API. Within a Lit Action, the example project calls the Weather API and then signs the weather response.

Here is the complete React project.

Additional Resources

Join our Developer Hub on Discord.

Check out our Grants program and get inspired on our Lit Ecosystem RFPs page.

Subscribe to the Lit Community Calendar to stay up to date on the latest developments.

Even more examples and resources can be found here.