Skip to content

Commit 60aca56

Browse files
committed
fix: README
1 parent ac9d04c commit 60aca56

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

solana-openai/nodejs/README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Solana + OpenAI Example within a Lit Action
22

3-
This code example demonstrates how an OpenAI API key can be used to generate a response to be signed by a Lit Solana Wrapped Key, all within the confines of Lit's Trusted Execution Environment (TEE).
3+
This code example demonstrates how an OpenAI API key can be used to generate a response, which is then signed by a Lit Solana Wrapped Keyall within the confines of Lit's Trusted Execution Environment (TEE).
44

55
## Prerequisites
66

7-
- An Ethereum private key
7+
- **An Ethereum private key**
88
- This private key will be used to:
99
- Own the PKP we mint. The minted PKP will be used to create new Wrapped Keys.
1010
- In order to pay for this, the corresponding Ethereum account must have Lit Test Tokens. If you do not have any, you can get some from [the faucet](https://chronicle-yellowstone-faucet.getlit.dev/)
11-
- An OpenAI API key. We will use this to make a quest to OpenAI with our query to generate a response.
12-
- This example currently used the GPT-4o-mini model, please enable this model on your API key or change it if needed.
13-
- This code example uses Node.js and Yarn. Please have these installed before running the example
11+
- **An OpenAI API key**
12+
- We will use this to make a request to OpenAI with our query to generate a response.
13+
- This example currently uses the GPT-4o-mini model, please enable this model on your API key or change it in the code if needed
14+
- **Node.js and Yarn**
15+
- Please have these installed before running the example
1416

1517
## Installation and Setup
1618

@@ -32,31 +34,30 @@ Here's an overview of how the code example works:
3234
1. Using an imported Ethereum private key, connect the wallet to the Lit RPC endpoint `Chronicle Yellowstone`
3335
2. Connect to the Lit network using the `LitNodeClient` on the `datil-dev` network
3436
3. Connect the `LitContracts` client to the Lit network (`datil-dev` in this case)
35-
4. **If not provided in the .env file**: Mint a PKP
36-
5. Create an AuthMethod using our Ethereum wallet
37-
6. Use the created AuthMethod to be the authentication in generating Session Signatures for our PKP
38-
7. Create a new Solana Wrapped Key
39-
8. Fetch the encrypted metadata of our Wrapped Key
40-
9. Define Access Control Conditions to encrypt our OpenAI API key with. This will ensure it is not revealed at any point. The ACCs are the same ones used to encrypt the Wrapped Key metadata.
41-
10. Write a simple prompt for our AI to answer
42-
11. Execute the Lit Action, providing our encrypted Solana Wrapped Key and OpenAI API key metadata, as well as our prompt.
37+
4. **If PKP idnot provided in the .env file**: Mint a new PKP.
38+
5. Use your Ethereum wallet to create an AuthMethod.
39+
6. Use the created AuthMethod for authentication in generating session signatures for our PKP.
40+
7. Generate a new Solana Wrapped Key.
41+
8. Retrieve the encrypted metadata of our Wrapped Key.
42+
9. Set up Access Control Conditions (ACCs) to encrypt our OpenAI API key. This ensures it is not revealed at any point. The ACCs are the same ones used to encrypt the Wrapped Key metadata.
43+
10. Write a simple prompt for the AI to answer.
44+
11. Run the Lit Action, providing our encrypted Solana Wrapped Key and OpenAI API key metadata, as well as our prompt.
4345

4446
### Lit Action Overview
4547

4648
Within the Lit Action:
4749

48-
1. Decrypt the Solana Wrapped Key and OpenAI API key
49-
2. Remove the salt from the decrypted Solana private key
50-
3. Query OpenAI for a response to the prompt
51-
4. Create a Solana keypair from the decrypted private key
52-
5. Use the Solana keypair to sign the OpenAI response
53-
6. Verify the signature
50+
1. Decrypt the Solana Wrapped Key and OpenAI API key.
51+
2. Remove the salt from the decrypted Solana private key.
52+
3. Send the prompt to OpenAI and receive a response.
53+
4. Generate a Solana keypair from the decrypted private key.
54+
5. Use the Solana keypair to sign the OpenAI response.
55+
6. Ensure the signature is valid.
5456

5557
### Expected Output
5658

5759
After running the test, the end of the output in the console should appear similar to:
5860

59-
6061
```ts
6162
Executed the Lit Action
6263
{
@@ -79,7 +80,7 @@ After running the test, the end of the output in the console should appear simil
7980

8081
## Specific Files to Reference
8182

82-
- [./src/index.ts](./src/index.ts): Contains the logic for the example
83+
- [./src/index.ts](./src/index.ts): Contains the core logic for the example
8384
- [./src/litAction.js](./src/litAction.js): Contains the Lit Action code that will be bundled
8485
- [./src/litAction.bundle.js](./src/litAction.bundle.js): Contains the bundled Lit Action code
8586
- [./src/utils.ts](./src/utils.ts): Contains the code for minting a new PKP and ensuring the required environment variables are set

0 commit comments

Comments
 (0)