Lit Protocol Integration Guide
LitProtocol is distributed cryptography for signing, encryption, and compute. A generalizable key management network, Lit provides you with a set of tools for managing sovereign identities on the open Web.
Combining Lit Protocol's pkp wallet with Account Kit allows you to use your Programmable Key Pairs (PKPs) as a smart account for your users.
WARNING
Lit Protocol's pkp network is still in testnet. Backwards compatibility, and data availability will not be guaranteed until mainnet. Do not use PKP wallets to store valuable assets.
Integration
Install the pkp ethers package
bash
npm i @lit-protocol/pkp-ethers@cayenne
bash
yarn add @lit-protocol/pkp-ethers@cayenne
Install the LitNodeClient
bash
npm i @lit-protocol/lit-node-client@cayenne
npm i @lit-protocol/crypto@cayenne
npm i @lit-protocol/auth-helpers@cayenne
bash
yarn add @lit-protocol/lit-node-client@cayenne
yarn add @lit-protocol/crypto@cayenne
yarn add @lit-protocol/auth-helpers@cayenne
Creating PKP
First we will need a pkp with an AuthMethod
See documentation here for creating PKPs
Create A LitSigner
ts
import { polygonMumbai } from "@alchemy/aa-core";
import { LitAuthMethod, LitSigner } from "@alchemy/aa-signers/lit-protocol";
const API_KEY = "<YOUR API KEY>";
const POLYGON_MUMBAI_RPC_URL = `${polygonMumbai.rpcUrls.alchemy.http[0]}/${API_KEY}`;
const PKP_PUBLIC_KEY = "<YOUR PKP PUBLIC KEY>";
export const createLitSignerWithAuthMethod = async () => {
return new LitSigner<LitAuthMethod>({
pkpPublicKey: PKP_PUBLIC_KEY,
rpcUrl: POLYGON_MUMBAI_RPC_URL,
});
};
Use it with Modular Account
We can link our SmartAccountSigner
to a Modular Account using createModularAccountAlchemyClient
from aa-alchemy
:
ts
import { createModularAccountAlchemyClient } from "@alchemy/aa-alchemy";
import { sepolia } from "@alchemy/aa-core";
import { createLitSigner } from "./lit";
const chain = sepolia;
const provider = await createModularAccountAlchemyClient({
apiKey: "ALCHEMY_API_KEY",
chain,
signer: await createLitSigner(AUTH_METHOD),
});