{"id":24988400,"url":"https://github.com/lit-protocol/lit-wrapper-sdk","last_synced_at":"2025-04-12T00:08:00.767Z","repository":{"id":267820905,"uuid":"902412813","full_name":"LIT-Protocol/lit-wrapper-sdk","owner":"LIT-Protocol","description":"custom sdk wrapper for lit protocol","archived":false,"fork":false,"pushed_at":"2024-12-26T13:43:41.000Z","size":956,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T06:07:39.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LIT-Protocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-12T14:16:25.000Z","updated_at":"2024-12-26T13:43:44.000Z","dependencies_parsed_at":"2024-12-21T22:28:50.507Z","dependency_job_id":null,"html_url":"https://github.com/LIT-Protocol/lit-wrapper-sdk","commit_stats":null,"previous_names":["anshss/lit-wrapper-sdk","lit-protocol/lit-hackers-sdk","lit-protocol/lit-wrapper-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIT-Protocol%2Flit-wrapper-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIT-Protocol%2Flit-wrapper-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIT-Protocol%2Flit-wrapper-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LIT-Protocol%2Flit-wrapper-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LIT-Protocol","download_url":"https://codeload.github.com/LIT-Protocol/lit-wrapper-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237111688,"owners_count":19257389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T12:04:08.659Z","updated_at":"2025-02-04T12:04:09.307Z","avatar_url":"https://github.com/LIT-Protocol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Lit Wrapper SDK\n\nUsing Lit Network has never been easier before\n\u003c/br\u003e An Ethereum private key is used to send requests to the Lit Network. Fund your wallet with a [faucet](https://chronicle-yellowstone-faucet.getlit.dev/) on Lit's custom rollup chain.\n\n## Quickview\n\n```bash\nnpm install lit-wrapper-sdk\n```\n\nGenerates a Solana key and sends a prompt to the Solana-agent-kit (This kit runs inside Lit's TEE)\n\n```js\nasync function executeSolanaAgentKit() {\n    const response = await litWrapper.createSolanaWK(ETHEREUM_PRIVATE_KEY);\n    const agentKitResponse = await litWrapper.executeSolanaAgentKit({\n        userPrivateKey: ETHEREUM_PRIVATE_KEY,\n        MESSAGE: \"What is my sol balance?\",\n        RPC_URL: \"https://api.devnet.solana.com\",\n        OPENAI_API_KEY: process.env.OPEN_AI_API_KEY!,\n        pkp: response?.pkpInfo!,\n        wk: response?.wkInfo!,\n    });\n    console.log(agentKitResponse);\n}\n```\n\nChecks against a conditional logic and only creates signatures for a specified transaction when the condition is satisfies\n\n```js\nasync function createLitActionAndSignSolanaTxn() {\n    const response = await litWrapper.createSolanaWK(ETHEREUM_PRIVATE_KEY);\n    console.log(\"Solana Public Key\", response?.wkInfo.generatedPublicKey);\n\n    const conditionLogic = `\n    const url = \"https://api.weather.gov/gridpoints/TOP/31,80/forecast\";\n    const resp = await fetch(url).then((response) =\u003e response.json());\n    const temp = resp.properties.periods[0].temperature;\n\n    console.log(temp);\n\n    // only sign if the temperature is below 60\n    if (temp \u003c 60) {\n        createSignatureWithAction();\n    }`;\n\n    const txn = await litWrapper.createSerializedLitTxn({\n        wk: response?.wkInfo,\n        toAddress: \"BTBPKRJQv7mn2kxBBJUpzh3wKN567ZLdXDWcxXFQ4KaV\",\n        amount: 0.004 * Math.pow(10, 9),\n        network: \"mainnet-beta\",\n        flag: FlagForLitTxn.SOL,\n    });\n\n    const checkResult = await litWrapper.conditionalSigningOnSolana({\n        userPrivateKey: ETHEREUM_PRIVATE_KEY,\n        litTransaction: txn,\n        conditionLogic,\n        broadcastTransaction: true,\n        wk: response?.wkInfo,\n        pkp: response?.pkpInfo,\n    });\n    console.log(checkResult);\n}\n```\n\n## API/Method References\n\n### `LitWrapper` Class\n\n#### Constructor\n```typescript\nconstructor(litNetwork: LIT_NETWORKS_KEYS)\n```\n- Initializes a new instance of the `LitWrapper` class.\n- **Parameters:**\n  - `litNetwork`: The Lit network key.\n\n#### Auth Methods\n\n##### `checkPermits`\n```typescript\nasync checkPermits(pkpTokenId: string): Promise\u003c{ actions: any[], authMethods: any[], addresses: any[] }\u003e\n```\n- Checks the permits of a PKP.\n- **Parameters:**\n  - `pkpTokenId`: The PKP token ID.\n- **Returns:** An object containing the permitted actions, auth methods, and addresses.\n\n##### `addAuthAddress`\n```typescript\nasync addAuthAddress(userPrivateKey: string, pkpTokenId: string, ethAddress: string): Promise\u003cany\u003e\n```\n- Adds an authorized address to a PKP.\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n  - `pkpTokenId`: The PKP token ID.\n  - `ethAddress`: The Ethereum address to authorize.\n- **Returns:** The response from the Lit network.\n\n##### `removeAuthAddress`\n```typescript\nasync removeAuthAddress(userPrivateKey: string, pkpTokenId: string, ethAddress: string): Promise\u003cany\u003e\n```\n- Adds an authorized address to a PKP.\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n  - `pkpTokenId`: The PKP token ID.\n  - `ethAddress`: The Ethereum address to authorize.\n- **Returns:** The response from the Lit network.\n\n##### `addPermittedAction`\n```typescript\nasync addPermittedAction(params: AddPermittedActionParams): Promise\u003c{ ipfsCID: string, response: any }\u003e\n```\n- Adds a permitted action to a PKP.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `pkpTokenId`, `litActionCode`, and `pinataAPIKey`.\n- **Returns:** An object containing the IPFS CID and the response.\n\n##### `removePermittedAction`\n```typescript\nasync removePermittedAction(params: RemovePermittedActionParams): Promise\u003c{ ipfsCID: string, response: any }\u003e\n```\n- Adds a permitted action to a PKP.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `pkpTokenId`, `litActionCode`, and `pinataAPIKey`.\n- **Returns:** An object containing the IPFS CID and the response.\n\n\n#### Solana Methods\n\n##### `createSolanaWK`\n```typescript\nasync createSolanaWK(userPrivateKey: string): Promise\u003c{ pkpInfo: PKP, wkInfo: WK }\u003e\n```\n- Creates a Solana Wrapped Key (WK).\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n- **Returns:** An object containing the PKP and WK information.\n\n##### `getConditionalLitAction`\n```typescript\nasync getConditionalLitAction(conditionalLogic: string): Promise\u003cstring\u003e\n```\n- Gets a conditional Lit action.\n- **Parameters:**\n  - `conditionalLogic`: The conditional logic.\n- **Returns:** The conditional Lit action.\n\n##### `conditionalSigningOnSolana`\n```typescript\nasync conditionalSigningOnSolana(params: ConditionalSigningOnSolanaParams): Promise\u003cany\u003e\n```\n- Performs conditional signing on Solana.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `litTransaction`, `broadcastTransaction`, `conditionalLogic`, `pkp`, `wk`, and `params`.\n- **Returns:** The result of the conditional signing.\n\n##### `executeCustomActionOnSolana`\n```typescript\nasync executeCustomActionOnSolana(params: ExecuteCustomActionOnSolanaParams): Promise\u003cany\u003e\n```\n- Executes a custom action on Solana.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `litActionCode`, `pkp`, `wk`, and `params`.\n- **Returns:** The result of the executed action.\n\n##### `executeSolanaAgentKit`\n```typescript\nasync executeSolanaAgentKit(params: ExecuteSolanaAgentKitParams): Promise\u003cany\u003e\n```\n- Executes the Solana Agent Kit.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `MESSAGE`, `RPC_URL`, `OPENAI_API_KEY`, `pkp`, and `wk`.\n- **Returns:** The result of the executed action.\n\n##### `sendSolanaWKTxnWithSol`\n```typescript\nasync sendSolanaWKTxnWithSol(params: SendSolanaWKTxnWithSolParams): Promise\u003cany\u003e\n```\n- Sends a Solana WK transaction with SOL.\n- **Parameters:**\n  - `params`: An object containing `amount`, `toAddress`, `network`, `broadcastTransaction`, `userPrivateKey`, `wk`, and `pkp`.\n- **Returns:** The signed transaction.\n\n##### `sendSolanaWKTxnWithCustomToken`\n```typescript\nasync sendSolanaWKTxnWithCustomToken(params: SendSolanaWKTxnWithCustomTokenParams): Promise\u003cany\u003e\n```\n- Sends a Solana WK transaction with a custom token.\n- **Parameters:**\n  - `params`: An object containing `tokenMintAddress`, `amount`, `toAddress`, `network`, `broadcastTransaction`, `userPrivateKey`, `wk`, and `pkp`.\n- **Returns:** The signed transaction.\n\n##### `createSerializedLitTxn`\n```typescript\nasync createSerializedLitTxn(params: CreateSerializedLitTxnParams): Promise\u003cany\u003e\n```\n- Creates a serialized Lit transaction.\n- **Parameters:**\n  - `params`: An object containing `toAddress`, `amount`, `network`, `flag`, `tokenMintAddress`, and `wk`.\n- **Returns:** The serialized transaction.\n\n#### Util Methods\n\n##### `createPKP`\n```typescript\nasync createPKP(userPrivateKey: string): Promise\u003cPKP | undefined\u003e\n```\n- Creates a PKP (Programmable Key Pair).\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n- **Returns:** The created PKP.\n\n##### `createPKPWithLitAction`\n```typescript\nasync createPKPWithLitAction(params: CreatePKPWithLitActionParams): Promise\u003c{ pkp: PKP, ipfsCID: string }\u003e\n```\n- Creates a PKP and adds a permitted action.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `litActionCode`, and `pinataAPIKey`.\n- **Returns:** An object containing the created PKP and the IPFS CID.\n\n##### `createPKPSessionSigs`\n```typescript\nasync createPKPSessionSigs(userPrivateKey: string, pkpPublicKey: string): Promise\u003cany\u003e\n```\n- Creates session signatures for a PKP.\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n  - `pkpPublicKey`: The PKP public key.\n- **Returns:** The session signatures.\n\n##### `getSessionSigs`\n```typescript\nasync getSessionSigs(userPrivateKey: string, pkpPublicKey: string, type: string): Promise\u003cany\u003e\n```\n- Gets session signatures.\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n  - `pkpPublicKey`: The PKP public key.\n  - `type`: The type of session.\n- **Returns:** The session signatures.\n\n##### `executeLitAction`\n```typescript\nasync executeLitAction(params: ExecuteLitActionParams): Promise\u003cany\u003e\n```\n- Executes a Lit action.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `pkpPublicKey`, `litActionIpfsCid`, `litActionCode`, and `params`.\n- **Returns:** The result of the executed action.\n\n##### `getDecipheringDetails`\n```typescript\nasync getDecipheringDetails(params: GetDecipheringDetailsParams): Promise\u003c{ ciphertext: string, dataToEncryptHash: string }\u003e\n```\n- Gets deciphering details.\n- **Parameters:**\n  - `params`: An object containing `userPrivateKey`, `pkp`, and `wk`.\n- **Returns:** An object containing the ciphertext and data to encrypt the hash.\n\n##### `uploadViaPinata`\n```typescript\nasync uploadViaPinata(params: UploadViaPinataParams): Promise\u003cstring\u003e\n```\n- Uploads a file to Pinata.\n- **Parameters:**\n  - `params`: An object containing `pinataAPIKey` and `litActionCode`.\n- **Returns:** The IPFS hash of the uploaded file.\n\n### `LitTester` Class\n\n#### Constructor\n```typescript\nconstructor(userPrivateKey: string, litNetwork: LIT_NETWORKS_KEYS)\n```\n- Initializes a new instance of the `LitTester` class.\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n  - `litNetwork`: The Lit network key.\n\n#### Methods\n\n##### `init`\n```typescript\nstatic async init(userPrivateKey: string, litNetwork: LIT_NETWORKS_KEYS): Promise\u003cLitTester\u003e\n```\n- Initializes a new instance of the `LitTester` class and initializes the PKP.\n- **Parameters:**\n  - `userPrivateKey`: The user's private key.\n  - `litNetwork`: The Lit network key.\n- **Returns:** The initialized `LitTester` instance.\n\n##### `initializePKP`\n```typescript\nasync initializePKP(): Promise\u003cvoid\u003e\n```\n- Initializes the PKP.\n- **Returns:** Nothing.\n\n##### `testLitAction`\n```typescript\nasync testLitAction(params: TestLitActionParams): Promise\u003cany\u003e\n```\n- Tests a Lit action.\n- **Parameters:**\n  - `params`: An object containing `litActionCode` and `params`.\n- **Returns:** The result of the tested action.\n\n### Enums\n\n#### `FlagForLitTxn`\n```typescript\nenum FlagForLitTxn {\n    SOL,\n    CUSTOM,\n}\n```\n- Enum for flags used in Lit transactions.\n- **Values:**\n  - `SOL`: Indicates a SOL transaction.\n  - `CUSTOM`: Indicates a custom token transaction.\n\n### Types\n\n#### `PKP`\n```typescript\ninterface PKP {\n    tokenId: string;\n    publicKey: string;\n    ethAddress: string;\n}\n```\n- Interface for a PKP (Programmable Key Pair).\n\n#### `WK`\n```typescript\ninterface WK {\n    pkpAddress: string;\n    id: string;\n    generatedPublicKey: string;\n}\n```\n- Interface for a Wrapped Key (WK).\n\n#### `AddPermittedActionParams`\n```typescript\ninterface AddPermittedActionParams {\n    userPrivateKey: string;\n    pkpTokenId: string;\n    litActionCode: string;\n    pinataAPIKey: string;\n}\n```\n- Interface for parameters used in adding a permitted action.\n\n#### `UploadViaPinataParams`\n```typescript\ninterface UploadViaPinataParams {\n    pinataAPIKey: string;\n    litActionCode: string;\n}\n```\n- Interface for parameters used in uploading via Pinata.\n\n#### `GetDecipheringDetailsParams`\n```typescript\ninterface GetDecipheringDetailsParams {\n    userPrivateKey: string;\n    pkp: PKP;\n    wk: WK;\n}\n```\n- Interface for parameters used in deciphering details.\n\n#### `CreatePKPWithLitActionParams`\n```typescript\ninterface CreatePKPWithLitActionParams {\n    userPrivateKey: string;\n    litActionCode: string;\n    pinataAPIKey: string;\n}\n```\n- Interface for parameters used in creating a PKP with a Lit action.\n\n#### `ExecuteLitActionParams`\n```typescript\ninterface ExecuteLitActionParams {\n    userPrivateKey: string;\n    pkpPublicKey: string;\n    litActionIpfsCid?: string;\n    litActionCode?: string;\n    params?: Object;\n}\n```\n- Interface for parameters used in executing a Lit action.\n\n#### `ConditionalSigningOnSolanaParams`\n```typescript\ninterface ConditionalSigningOnSolanaParams {\n    userPrivateKey: string;\n    litTransaction: any;\n    broadcastTransaction: boolean;\n    conditionalLogic: string;\n    pkp?: PKP;\n    wk?: WK;\n    params?: Object;\n}\n```\n- Interface for parameters used in conditional signing on Solana.\n\n#### `ExecuteCustomActionOnSolanaParams`\n```typescript\ninterface ExecuteCustomActionOnSolanaParams {\n    userPrivateKey: string;\n    litActionCode: string;\n    pkp?: PKP;\n    wk?: WK;\n    params?: Object;\n}\n```\n- Interface for parameters used in executing a custom action on Solana.\n\n#### `ExecuteSolanaAgentKitParams`\n```typescript\ninterface ExecuteSolanaAgentKitParams {\n    userPrivateKey: string;\n    MESSAGE: string;\n    RPC_URL: string;\n    OPENAI_API_KEY: string;\n    pkp?: PKP;\n    wk?: WK;\n}\n```\n- Interface for parameters used in executing the Solana Agent Kit.\n\n#### `CreateSerializedLitTxnParams`\n```typescript\ninterface CreateSerializedLitTxnParams {\n    toAddress: string;\n    amount: number;\n    network: Cluster;\n    flag: FlagForLitTxn;\n    tokenMintAddress?: string;\n    wk?: WK;\n}\n```\n- Interface for parameters used in creating a serialized Lit transaction.\n\n#### `SendSolanaWKTxnWithSolParams`\n```typescript\ninterface SendSolanaWKTxnWithSolParams {\n    amount: number;\n    toAddress: string;\n    network: Cluster;\n    broadcastTransaction: boolean;\n    userPrivateKey: string;\n    wk?: WK;\n    pkp?: PKP;\n}\n```\n- Interface for parameters used in sending a Solana WK transaction with SOL.\n\n#### `SendSolanaWKTxnWithCustomTokenParams`\n```typescript\ninterface SendSolanaWKTxnWithCustomTokenParams {\n    tokenMintAddress: string;\n    amount: number;\n    toAddress: string;\n    network: Cluster;\n    broadcastTransaction: boolean;\n    userPrivateKey: string;\n    wk?: WK;\n    pkp?: PKP;\n}\n```\n- Interface for parameters used in sending a Solana WK transaction with a custom token.\n\n#### `TestLitActionParams`\n```typescript\ninterface TestLitActionParams {\n    litActionCode: string;\n    params: Object;\n}\n```\n- Interface for parameters used in testing a Lit action.\n\n\n## Examples\n\n### 1) Creating a Key on Solana and Sending Transaction\n\nUsing Lit to create a Solana Key and send a Txn with it, an Ethereum private key is used as an auth method for generating signatures with a newly created Solana Key. \n\n```js\nimport { LitWrapper } from \"lit-wrapper-sdk\";\nimport \"dotenv/config\";\n\nconst litWrapper = new LitWrapper(\"datil-dev\")\n\nasync function generateSolanaWallet() {\n    const res = await litWrapper.createSolanaWK(ETHEREUM_PRIVATE_KEY);\n    console.log(\"Solana Public Key\", res.wkInfo.generatedPublicKey);\n}\n\nasync function sendSolTxn() {\n    const signedTx = await litWrapper.sendSolanaWKTxnWithSol({\n        amount: 0.0022 * Math.pow(10, 9),\n        toAddress: \"BTBPKRJQv7mn2kxBBJUpzh3wKN567ZLdXDWcxXFQ4KaV\",\n        network: \"mainnet-beta\",\n        broadcastTransaction: true,\n        userPrivateKey: ETHEREUM_PRIVATE_KEY,\n        wkResponse: res.wkInfo,\n        pkp: res.pkpInfo,\n    });\n    console.log(\"Transaction Hash: \", signedTx);\n}\n\nasync function sendBONKTxn() {\n    const signedTx = await litWrapper.sendSolanaWKTxnWithCustomToken({\n        tokenMintAddress: \"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263\", // BONK MINT TOKEN\n        amount: 4 * Math.pow(10, 5),\n        toAddress: \"BTBPKRJQv7mn2kxBBJUpzh3wKN567ZLdXDWcxXFQ4KaV\",\n        network: \"mainnet-beta\",\n        broadcastTransaction: true,\n        userPrivateKey: ETHEREUM_PRIVATE_KEY,\n        wkResponse: res.wkInfo,\n        pkp: res.pkpInfo,\n    });\n    console.log(\"Transaction Hash: \", signedTx);\n}\n```\n\n### 2) Creating Conditional Signing on Solana\n\nChecks against a conditional logic and only creates signatures for a specified transaction when the condition is satisfies\n\n```js\nasync function createLitActionAndSignSolanaTxn() {\n    const response = await litWrapper.createSolanaWK(ETHEREUM_PRIVATE_KEY);\n    console.log(\"Solana Public Key\", response?.wkInfo.generatedPublicKey);\n\n    const conditionLogic = `\n    const url = \"https://api.weather.gov/gridpoints/TOP/31,80/forecast\";\n    const resp = await fetch(url).then((response) =\u003e response.json());\n    const temp = resp.properties.periods[0].temperature;\n\n    console.log(temp);\n\n    // only sign if the temperature is below 60\n    if (temp \u003c 60) {\n        createSignatureWithAction();\n    }`;\n\n    const txn = await litWrapper.createSerializedLitTxn({\n        wk: response?.wkInfo,\n        toAddress: \"BTBPKRJQv7mn2kxBBJUpzh3wKN567ZLdXDWcxXFQ4KaV\",\n        amount: 0.004 * Math.pow(10, 9),\n        network: \"mainnet-beta\",\n        flag: FlagForLitTxn.SOL,\n    });\n\n    const checkResult = await litWrapper.conditionalSigningOnSolana({\n        userPrivateKey: ETHEREUM_PRIVATE_KEY,\n        litTransaction: txn,\n        conditionLogic,\n        broadcastTransaction: true,\n        wk: response?.wkInfo,\n        pkp: response?.pkpInfo,\n    });\n    console.log(checkResult);\n}\n```\n\n### 3) Executing Custom AI Powered Lit Actions\n\n```js\nasync function executeCustomLitAction() {\n    const response = await litWrapper.createSolanaWK(ETHEREUM_PRIVATE_KEY);\n    const litActionCode = `\n    const go = async () =\u003e {\n        try {\n            const callAI = await LitActions.runOnce({ \n                waitForResponse: true, name: \"Lit Actions Test\" },\n                async () =\u003e {\n                    const messages = [\n                        { role: \"system\", content: \"You are an AI assistant. Only answer with a single sentence.\" },\n                    ];\n                    const response = await fetch(\n                    \"https://api.openai.com/v1/chat/completions\",\n                    {\n                        method: \"POST\",\n                        headers: {\n                            \"Content-Type\": \"application/json\",\n                            Authorization: \\`Bearer \\${apiKey}\\`,\n                        },\n                        body: JSON.stringify({ model: \"gpt -4o-mini\", messages }),\n                    });\n                    const json = await response.json();\n                    console.log(json);\n                    return json.choices[0].message;\n                });\n            console.log(callAI);\n            Lit.Actions.setResponse({ response: callAI });\n        } catch (error) {\n            Lit.Actions.setResponse({ response: error.message });\n        }\n    }; go();`;\n\n    const result = await litWrapper.executeCustomActionOnSolana({\n        userPrivateKey: ETHEREUM_PRIVATE_KEY,\n        litActionCode,\n        pkp: response?.pkpInfo!,\n        wk: response?.wkInfo!,\n        params: {\n            apiKey: process.env.OPEN_AI_API_KEY,\n        },\n    });\n    console.log(result);\n}\n```\n\n\n### 4) Creating a key on EVM and Executing a Lit Action\n\nCreate a key, Upload Lit Action to IPFS, Permit on IPFS and Execute the action.\n\n```js\nimport { LitWrapper } from \"lit-wrapper-sdk\";\nimport \"dotenv/config\";\n\nconst litWrapper = new LitWrapper(\"datil-dev\");\n\nasync function createKeyAndExecuteAction() {\n    const _litActionCode = async () =\u003e {\n        try {\n            const sigShare = await Lit.Actions.ethPersonalSignMessageEcdsa({\n                message: dataToSign,\n                publicKey: pkpPublicKey,\n                sigName,\n            });\n            Lit.Actions.setResponse({ response: sigShare });\n        } catch (error) {\n            Lit.Actions.setResponse({ response: error.message });\n        }\n    };\n    const litActionCode = `(${_litActionCode.toString()})();`;\n\n    const { pkp, ipfsCID } = await litWrapper.createPKPWithLitAction(\n        process.env.ETHEREUM_PRIVATE_KEY,\n        litActionCode,\n        process.env.PINATA_API_KEY\n    );\n\n    const params = {\n        dataToSign: ethers.utils.arrayify(\n            ethers.utils.keccak256([1, 2, 3, 4, 5])\n        ),\n        sigName: \"sig1\",\n    }\n\n    const response = litWrapper.executeLitAction(usePrivateKey, pkp, ipfsCID, params);\n    console.log(response)\n}\n```\n\n### 5) Testing a Lit Action\n\nInstantly create a Lit Action and test its execution over Lit Network.\n\n```js\nasync function testAction() {\n    if (!process.env.ETHEREUM_PRIVATE_KEY) {\n        throw new Error(\"ETHEREUM_PRIVATE_KEY is not set\");\n    }\n\n    const _litActionCode = async () =\u003e {\n        try {\n            const sigShare = await Lit.Actions.ethPersonalSignMessageEcdsa({\n                message: dataToSign,\n                publicKey: pkpPublicKey,\n                sigName,\n            });\n            Lit.Actions.setResponse({ response: sigShare });\n        } catch (error) {\n            Lit.Actions.setResponse({ response: error.message });\n        }\n    };\n    const litActionCode = `(${_litActionCode.toString()})();`;\n\n    const tester = await LitTester.init(\n        process.env.ETHEREUM_PRIVATE_KEY,\n        \"datil-dev\"\n    );\n\n    const params = [\n        {\n            dataToSign: ethers.utils.arrayify(\n                ethers.utils.keccak256([1, 2, 3, 4, 5])\n            ),\n            sigName: \"sig1\",\n        }\n    ];\n\n    const results = await tester.testLitAction(litActionCode, params[0]);\n    console.log(\"Test Results: \", results);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flit-protocol%2Flit-wrapper-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flit-protocol%2Flit-wrapper-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flit-protocol%2Flit-wrapper-sdk/lists"}