### Example Implementation: Generating a Wrapped Key Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/wrapped-keys/generating-wrapped-key.md This section provides a step-by-step guide and code examples for implementing the `generatePrivateKey` function, including installing dependencies and instantiating an Ethers signer. ```APIDOC ## Example Implementation: Generating a Wrapped Key ### Installing the Required Dependencies ```bash npm install \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-auth-client \ @lit-protocol/lit-node-client \ @lit-protocol/wrapped-keys \ ethers@v5 ``` ### Instantiating an Ethers Signer ```ts import * as ethers from 'ethers'; import { LIT_RPC } from "@lit-protocol/constants"; const ethersSigner = new ethers.Wallet( process.env.ETHEREUM_PRIVATE_KEY, new ethers.providers.JsonRpcProvider(LIT_RPC.CHRONICLE_YELLOWSTONE) ); ``` ``` -------------------------------- ### Clone and Install Dependencies Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/openfort.md Clone the Openfort sample repository and install the necessary npm packages to get started. ```bash git clone https://github.com/openfort-xyz/samples/ cd lit-protocol npm install ``` -------------------------------- ### Install Dependencies for OrbisDB Example Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/storage/orbis-example.md Clone the example repository and install project dependencies using npm. Ensure you have Node v20 or later installed. ```bash git clone https://github.com/ceramicstudio/orbisdb-lit-example && cd orbisdb-lit-example npm install ``` -------------------------------- ### Copy Environment Example File Source: https://github.com/lit-protocol/docs/blob/main/README.md Copies the example environment file to be used for local configuration. Remember to fill in the secrets. ```bash cp .env.example .env ``` -------------------------------- ### Start Development Server Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/openfort.md Run the npm development script to start the local server and access the application at http://localhost:3000. ```bash npm run dev ``` -------------------------------- ### Start Local Development Server Source: https://github.com/lit-protocol/docs/blob/main/README.md Starts a local development server for live previewing changes. Changes are reflected without server restarts. ```bash yarn start ``` -------------------------------- ### Install LitAuthClient and Providers Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/minting/via-social.md Install the necessary packages for Lit authentication client and providers using yarn. ```bash yarn add @lit-protocol/lit-auth-client yarn add @lit-protocol/providers ``` -------------------------------- ### Dependencies Installation Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/wrapped-keys/exporting-wrapped-key.md Instructions for installing the necessary dependencies for using the Lit Protocol SDK, including wrapped keys functionality. ```APIDOC ### Installing the Required Dependencies #### npm ```bash npm install \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-auth-client \ @lit-protocol/lit-node-client \ @lit-protocol/wrapped-keys \ ethers@v5 ``` #### yarn ```bash yarn add \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-auth-client \ @lit-protocol/lit-node-client \ @lit-protocol/wrapped-keys \ ethers@v5 ``` ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/candide.md Install the necessary AbstractionKit and Lit Protocol dependencies using npm. ```bash npm i abstractionkit@0.1.12 @lit-protocol/lit-node-client @lit-protocol/lit-auth-client @lit-protocol/constants ``` -------------------------------- ### Install Lit SDK Dependencies with npm Source: https://github.com/lit-protocol/docs/blob/main/docs/intro/first-request/making-first-signing.md Install the necessary packages for PKP signing with the Lit SDK using npm. Ensure you have `ethers@v5` installed for wallet operations. ```bash npm install @lit-protocol/lit-node-client \ @lit-protocol/constants \ @lit-protocol/auth-helpers \ @lit-protocol/contracts-sdk \ ether@v5 ``` -------------------------------- ### Install Lit Protocol Packages Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/minting/via-contracts.md Install the necessary packages for interacting with Lit Protocol contracts and clients. Ensure you have Node.js and Yarn installed. ```bash yarn add @lit-protocol/lit-node-client yarn add @lit-protocol/lit-auth-client yarn add @lit-protocol/contracts-sdk yarn add @lit-protocol/constants yarn add @lit-protocol/providers ``` -------------------------------- ### Install Lit Protocol Packages Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/minting/via-multiple-auth-methods.md Install the necessary Lit Protocol packages for using the ContractsSDK and authentication client. ```bash yarn add @lit-protocol/lit-auth-client yarn add @lit-protocol/contracts-sdk ``` -------------------------------- ### Install Lit Node Client Packages Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/alchemy-account-kit.md Install the LitNodeClient, crypto, and auth-helpers packages using npm or yarn. ```bash npm i @lit-protocol/lit-node-client npm i @lit-protocol/crypto npm i @lit-protocol/auth-helpers ``` ```bash yarn add @lit-protocol/lit-node-client yarn add @lit-protocol/crypto yarn add @lit-protocol/auth-helpers ``` -------------------------------- ### Install Lit Protocol Packages Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/pimlico.md Installs necessary packages for Lit Protocol integration. Ensure you have Node.js and npm installed. ```bash npm install stytch @lit-protocol/pkp-ethers @lit-protocol/lit-auth-client @lit-protocol/auth-helpers @lit-protocol/types @lit-protocol/lit-node-client-nodejs ``` -------------------------------- ### Install LitAuthClient Package Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/minting/via-multiple-auth-methods.md Install the LitAuthClient package using yarn to enable authentication flows. ```bash yarn add @lit-protocol/lit-auth-client ``` -------------------------------- ### Install Lit Protocol SDK Packages Source: https://context7.com/lit-protocol/docs/llms.txt Install the necessary Lit Protocol SDK packages for browser and Node.js environments. Ensure you have ethers@v5 installed. ```bash # For browser and Node.js environments npm install @lit-protocol/lit-node-client @lit-protocol/constants @lit-protocol/auth-helpers ethers@v5 # For Node.js only (server-side) npm install @lit-protocol/lit-node-client-nodejs @lit-protocol/constants @lit-protocol/auth-helpers ethers@v5 # Additional packages for PKP/wallet functionality npm install @lit-protocol/contracts-sdk @lit-protocol/lit-auth-client ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/lit-protocol/docs/blob/main/README.md Run this command to install all necessary dependencies for the project using Yarn. ```bash yarn ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/lit-protocol/docs/blob/main/docs/paying-for-lit/delegating-credit.md Installs the required packages for delegating a Capacity Credit using npm. ```bash npm install \ @lit-protocol/constants \ @lit-protocol/lit-node-client \ ethers@v5 ``` -------------------------------- ### Install pkp-ethers Package Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/alchemy-account-kit.md Install the pkp ethers package using npm or yarn. ```bash npm i @lit-protocol/pkp-ethers ``` ```bash yarn add @lit-protocol/pkp-ethers ``` -------------------------------- ### Install Wrapped Keys SDK with npm Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/wrapped-keys/overview.md Install the Wrapped Keys SDK using npm. Ensure you are using version 6.4.0 or higher. ```bash npm i @lit-protocol/wrapped-keys ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/lit-protocol/docs/blob/main/docs/paying-for-lit/minting-capacity-credit/via-contract.md Installs the necessary Lit Protocol packages and ethers for Node.js projects using npm. ```bash npm install \ @lit-protocol/constants \ @lit-protocol/contracts-sdk \ ethers@v5 ``` -------------------------------- ### Install Dependencies for Lit Protocol and ComposeDB Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/storage/ceramic-example.md Clone the repository and install project dependencies using npm. Ensure you have Node.js v16 or higher. ```bash git clone https://github.com/ceramicstudio/lit-composedb && cd lit-composedb npm install ``` -------------------------------- ### Install Lit SDK Dependencies with npm Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/authentication/session-sigs/get-pkp-session-sigs.md Install the necessary Lit SDK packages and ethers v5 using npm. This command is for Node.js environments. ```bash npm install \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-node-client \ @lit-protocol/contracts-sdk \ @lit-protocol/lit-auth-client \ ethers@v5 ``` -------------------------------- ### Setup AuthSig and PKP with GetLit CLI Source: https://github.com/lit-protocol/docs/blob/main/docs/tools/getlit-cli.md The 'getlit setup' command is used to mint a Public Key (PKP) and create an AuthSig, which are necessary for building and deploying Lit projects. ```bash getlit setup ``` -------------------------------- ### React App Rewired Start Script Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/migrations/3.0.0/overview.md Example of modifying the start script in package.json to use react-app-rewired for custom webpack configurations in Create React App. ```json "scripts: { ... "start": "react-app-rewired start", } ``` -------------------------------- ### Get RPC URL from All Nodes in Parallel Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/serverless-signing/get-rpc-url.md Use `Lit.Actions.getRpcUrl` to fetch an RPC URL for a specified chain. This example demonstrates making an RPC call to get transactions from the latest block on Ethereum, executed by all nodes in parallel. ```javascript (async () => { const rpcUrl = await Lit.Actions.getRpcUrl({ chain: "ethereum" }); const blockByNumber = await provider.send("eth_getBlockByNumber", ["latest", false]); const transactions = blockByNumber.transactions; Lit.Actions.setResponse(JSON.stringify(transactions)); })(); ``` -------------------------------- ### Solana Transaction Confirmation and Details Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/wrapped-keys/sign-transaction.md Use these snippets to get the status and details of a Solana transaction after it has been signed and broadcasted. Ensure you have the @solana/web3.js SDK installed. ```ts const status = await solanaConnection.getSignatureStatus(signedTx); // { context: { apiVersion: '2.0.5', slot: 321490377 }, value: { confirmationStatus: 'confirmed', confirmations: 0, err: null, slot: 321490377, status: { Ok: null } } } const confirmation = await solanaConnection.confirmTransaction(signedTx); // { context: { slot: 321490379 }, value: { err: null } } ``` ```ts import { Connection, clusterApiUrl, } from '@solana/web3.js'; const chain = 'devnet'; const transactionSignature = await signTransactionWithEncryptedKey({ // This parameter values are not included here for brevity, // but follow the other code examples in this guide. // // pkpSessionSigs, // network: 'solana', // unsignedTransaction, // broadcast: true, // litNodeClient, }); // Wait for confirmation and fetch the transaction details const signatureBuffer = Buffer.from(transactionSignature, 'base64'); const solanaConnection = new Connection(clusterApiUrl(chain), 'confirmed'); const confirmation = await solanaConnection.confirmTransaction(signatureBuffer); console.log('Transaction confirmation status:', confirmation.value); const transactionReceipt = await solanaConnection.getTransaction( signatureBuffer.toString('base64'), { commitment: 'confirmed' }, ); ``` -------------------------------- ### Define Custom Auth Methods for SIWS Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/authentication/session-sigs/siws-pkp-session-sigs.md Define unique identifiers for custom authentication methods, such as a Lit Developer Guide Solana SIWS Example, and a specific ID for a given Solana public key. ```typescript const authMethodType = ethers.utils.keccak256( // This can be anything, but should be unique to your app ethers.utils.toUtf8Bytes("Lit Developer Guide Solana SIWS Example") ); const authMethodId = ethers.utils.keccak256( ethers.utils.toUtf8Bytes(`siws:${solanaPublicKey}`) ); ``` -------------------------------- ### Initialize New Lit Project with GetLit CLI Source: https://github.com/lit-protocol/docs/blob/main/docs/tools/getlit-cli.md Use the 'getlit action' command to initialize a new Lit project. This sets up the basic directory structure and configuration files. ```bash getlit action ``` -------------------------------- ### Configure Openfort API Keys Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/openfort.md Copy the example environment file and replace placeholders with your Openfort publishable and secret API keys. ```bash cp .env.local.example .env.local ``` ```env NEXT_PUBLIC_OPENFORT_PUBLIC_KEY="" NEXTAUTH_OPENFORT_SECRET_KEY="" ``` -------------------------------- ### Install yarn Dependencies for Wrapped Keys Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/wrapped-keys/listing-wrapped-keys.md Install the required yarn packages for interacting with Lit Protocol's Wrapped Keys. Ensure you have Node.js and yarn installed. ```bash yarn add \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-auth-client \ @lit-protocol/lit-node-client \ @lit-protocol/wrapped-keys \ ethers@v5 ``` -------------------------------- ### Initialize LitNodeClient and LitRelay Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/claimable-keys/usage.md Set up the LitNodeClient and LitRelay instances. Ensure the correct Lit network and relay URL are used. A test API key is used here. ```javascript import { LitRelay } from '@lit-protocol/lit-auth-client'; import { StytchOtpProvider } from '@lit-protocol/providers'; import { LitNodeClient } from '@lit-protocol/lit-node-client'; import { LIT_NETWORK, PROVIDER_TYPE } from '@lit-protocol/constants'; const litNodeClient = new LitNodeClient({ litNetwork: LIT_NETWORK.DatilDev, debug: true, }); await litNodeClient.connect(); const litRelay = new LitRelay({ relayUrl: LitRelay.getRelayUrl(LIT_NETWORK.DatilDev), relayApiKey: 'test-api-key', }); ``` -------------------------------- ### Install npm Dependencies for Wrapped Keys Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/wrapped-keys/listing-wrapped-keys.md Install the required npm packages for interacting with Lit Protocol's Wrapped Keys. Ensure you have Node.js and npm installed. ```bash npm install \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-auth-client \ @lit-protocol/lit-node-client \ @lit-protocol/wrapped-keys \ ethers@v5 ``` -------------------------------- ### Claim Key with ClientClaimProcessor and contracts-sdk Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/claimable-keys/usage.md This example demonstrates claiming a key using a custom `ClientClaimProcessor` that integrates with the `contracts-sdk` for on-chain registration. You need to provide a signer and a `mintCallback` function. ```jsx import { LitContracts } from '@lit-protocol/contracts-sdk'; import { ClaimRequest, ClaimResult, ClientClaimProcessor } from "@lit-protocol/types" import { LIT_RPC, LIT_NETWORK } from "@lit-protocol/constants"; const client = new LitNodeClient({ litNetwork: LIT_NETWORK.DatilDev, debug: false }); await client.connect(); let claimReq: ClaimRequest = { authMethod, signer: new ethers.Wallet("", new ethers.providers.JsonRpcProvider(LIT_RPC.CHRONICLE_YELLOWSTONE)), mintCallback: async (claimRes: ClaimResult) => { const litContracts = new LitContracts({ signer: claimRes.signer }); await litContracts.connect(); let tokenId = await litContracts.pkpNftContractUtils.write.claimAndMint(claimRes.derivedKeyId, claimRes.signatures); return tokenId.tokenId } }; let res = await client.claimKeyId(claimReq); console.log("mint tx hash: ", res.mintTx); console.log("pkp public key: ", res.pubkey); ``` -------------------------------- ### Install Node.js Dependencies for Irys and Lit Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/storage/irys.md Installs necessary npm packages for integrating Irys and Lit Protocol in a Node.js environment. Ensure you have Node.js and npm installed. ```bash npm install \ @lit-protocol/lit-node-client-nodejs \ @lit-protocol/constants \ @irys/upload \ @irys/upload-ethereum \ ethers \ siwe \ dotenv ``` -------------------------------- ### Start site with a specific locale Source: https://github.com/lit-protocol/docs/blob/main/not-docs/tutorial-extras/translate-your-site.md Run the development server with the '--locale' flag to preview your site in a specific language during development. ```bash npm run start -- --locale fr ``` -------------------------------- ### Install Lit SDK Dependencies with yarn Source: https://github.com/lit-protocol/docs/blob/main/docs/intro/first-request/making-first-signing.md Install the necessary packages for PKP signing with the Lit SDK using yarn. Ensure you have `ethers@v5` installed for wallet operations. ```bash yarn add @lit-protocol/lit-node-client \ @lit-protocol/constants \ @lit-protocol/auth-helpers \ @lit-protocol/contracts-sdk \ ether@v5 ``` -------------------------------- ### Initialize PKP Wallets with LitNodeClient Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/migrations/7.0.0.md Initialize PKP wallets using the new PKPEthersWallet class, which requires a LitNodeClient instance. This replaces the older method that did not require explicit client initialization. ```jsx const pkpEthersWallet = new PKPEthersWallet({ pkpPublicKey, controllerAuthSig }); ``` ```jsx import { LitNodeClient } from '@lit-protocol/lit-node-client'; const litNodeClient = new LitNodeClient(); await litNodeClient.connect(); const pkpEthersWallet = new PKPEthersWallet({ pkpPublicKey, controllerAuthSig, litNodeClient, }); ``` -------------------------------- ### Setup ContractsSDK Client for Minting PKP Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/minting/via-multiple-auth-methods.md Configure your Ethereum provider and controller wallet, then initialize the LitContracts client with network settings to prepare for PKP minting. ```javascript import { LitContracts } from '@lit-protocol/contracts-sdk'; import { LIT_NETWORK } from "@lit-protocol/constants"; const ethersWallet = new ethers.Wallet( 'Your Private Key', // Replace with your private key new ethers.providers.JsonRpcProvider(LIT_RPC.CHRONICLE_YELLOWSTONE) ); const contractClient = new LitContracts({ signer: ethersWallet, network: LIT_NETWORK.DatilTest, }); await contractClient.connect(); ``` -------------------------------- ### Initialize Lit Clients and Google Provider Source: https://github.com/lit-protocol/docs/blob/main/docs/integrations/aa/candide.md Connect to the Lit Network, set up the LitRelay for authentication, and initialize a GoogleProvider for Google sign-in. This sets up the necessary clients for authentication. ```jsx import { LitNodeClient } from "@lit-protocol/lit-node-client"; import { LitRelay } from "@lit-protocol/lit-auth-client"; import { GoogleProvider } from "@lit-protocol/providers"; import { PROVIDER_TYPE, LIT_NETWORK } from "@lit-protocol/constants"; const initalizeClientsAndProvider = async () => { const litNodeClient = new LitNodeClient({ litNetwork: LIT_NETWORK.DatilDev, debug: true, }); await litNodeClient.connect(); const litRelay = new LitRelay({ relayUrl: LitRelay.getRelayUrl(LIT_NETWORK.DatilDev), relayApiKey: 'test-api-key', }); console.log("Connected to Lit Nodes and Lit Relay ✔️"); const provider = new GoogleProvider({ relay: litRelay, litNodeClient }); return { litNodeClient, litRelay, provider }; }; ``` -------------------------------- ### Install Dependencies with yarn Source: https://github.com/lit-protocol/docs/blob/main/docs/paying-for-lit/delegating-credit.md Installs the required packages for delegating a Capacity Credit using yarn. ```bash yarn add \ @lit-protocol/constants \ @lit-protocol/lit-node-client \ ethers@v5 ``` -------------------------------- ### Use PKP as an Ethers Signer (v5 vs v6) Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/migrations/6.0.0.md Initializes a PKPEthersWallet. v5 requires controllerAuthMethods, controllerAuthSig, and rpc. v6 requires controllerSessionSigs and litNodeClient. ```typescript // v5 import { PKPEthersWallet } from '@lit-protocol/pkp-ethers'; const pkpEthersWallet = new PKPEthersWallet({ controllerAuthMethods, controllerAuthSig, pkpPubKey, rpc, litNetwork: globalThis.LitCI.network, }); ``` ```typescript // v6 import { PKPEthersWallet } from '@lit-protocol/pkp-ethers'; const pkpEthersWallet = new PKPEthersWallet({ controllerSessionSigs, litNodeClient, pkpPubKey, }); ``` -------------------------------- ### Install yarn Dependencies for Lit SDK Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/authentication/session-sigs/get-lit-action-session-sigs.md Install the necessary yarn packages for using the Lit SDK, including auth helpers, constants, node client, contracts SDK, ipfs-only-hash, and ethers v5. Ensure you have Node.js and yarn installed. ```bash yarn add \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-node-client \ @lit-protocol/contracts-sdk \ ipfs-only-hash \ ether@v5 ``` -------------------------------- ### Initialize PKPWalletConnect with WalletConnect Configuration Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/walletconnect.md Initializes the PKPWalletConnect instance with WalletConnect configuration, including project ID and metadata. Ensure you have a WalletConnect project ID. ```javascript const config = { projectId: "", metadata: { name: "Test Lit Wallet", description: "Test Lit Wallet", url: "https://litprotocol.com/", icons: ["https://litprotocol.com/favicon.png"], }, }; await pkpWalletConnect.initWalletConnect(config); ``` -------------------------------- ### Initialize StytchOtpProvider and Authenticate Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/claimable-keys/usage.md Create an instance of the StytchOtpProvider, passing the relay and LitNodeClient. Then, authenticate using the Stytch session JWT. ```javascript // Initialize StytchOtp provider const stytchProvider = new StytchOtpProvider({ relay, litNodeClient }); const authMethod = await stytchProvider.authenticate({ accessToken: sessionStatus.session_jwt }); ``` -------------------------------- ### Install npm Dependencies for Lit SDK Source: https://github.com/lit-protocol/docs/blob/main/docs/sdk/authentication/session-sigs/get-lit-action-session-sigs.md Install the necessary npm packages for using the Lit SDK, including auth helpers, constants, node client, contracts SDK, ipfs-only-hash, and ethers v5. Ensure you have Node.js and npm installed. ```bash npm install \ @lit-protocol/auth-helpers \ @lit-protocol/constants \ @lit-protocol/lit-node-client \ @lit-protocol/contracts-sdk \ ipfs-only-hash \ ether@v5 ``` -------------------------------- ### Authenticate and Mint PKP via Relayer Source: https://github.com/lit-protocol/docs/blob/main/docs/user-wallets/pkps/minting/via-contracts.md Authenticate using an ethers wallet and mint a PKP through the Lit relayer. This example demonstrates setting up the LitNodeClient, LitRelay, and EthWalletProvider, and defining a `signMessage` callback for authentication. ```javascript import { LitNodeClient } from '@lit-protocol/lit-node-client'; import { LitRelay } from '@lit-protocol/lit-auth-client'; import { AUTH_METHOD_SCOPE, AUTH_METHOD_TYPE, PROVIDER_TYPE, LIT_RPC, LIT_NETWORK } from '@lit-protocol/constants'; import { EthWalletProvider } from '@lit-protocol/providers'; import * as ethers from 'ethers'; const litNodeClient = new LitNodeClient({ litNetwork: LIT_NETWORK.DatilDev, debug: true }) await litNodeClient.connect(); const litRelay = new LitRelay({ relayUrl: LitRelay.getRelayUrl(LIT_NETWORK.DatilDev), relayApiKey: 'test-api-key', }); const ethWalletProvider = new EthWalletProvider({ relay: litRelay, litNodeClient }); const ethersWallet = new ethers.Wallet( 'Your Ethereum Private Key', // Replace with your private key new ethers.providers.JsonRpcProvider(LIT_RPC.CHRONICLE_YELLOWSTONE) ); const authMethod = await ethWalletProvider.authenticate({ signMessage: (message: string) => { return await ethersWallet.signMessage(message); } }); const options = { permittedAuthMethodScopes: [[AUTH_METHOD_SCOPE.SignAnything]], }; const mintTx = await litRelay.mintPKPWithAuthMethods([authMethod], options); ``` -------------------------------- ### Install Dependencies with yarn Source: https://github.com/lit-protocol/docs/blob/main/docs/paying-for-lit/minting-capacity-credit/via-contract.md Installs the necessary Lit Protocol packages and ethers for Node.js projects using yarn. ```bash yarn add \ @lit-protocol/constants \ @lit-protocol/contracts-sdk \ ethers@v5 ```