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.
Integration
Install the pkp ethers package
npm
npm i @lit-protocol/pkp-ethers@cayenne
Install the LitNodeClient
npm
npm i @lit-protocol/lit-node-client@cayenne
npm i @lit-protocol/crypto@cayenne
npm i @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
lit.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
:
example.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),
});