Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: solana wallet GPT example #234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

user-64bit
Copy link

Pull Request Description

The PR adds AI powered wallet-gpt in example

Related Issue

Fixes #126

Changes Made

This PR adds the following changes:

  • add wallet gpt in example
  • integrate AI powered wallet-gpt

Implementation Details

  • Tech Stack: Next.js, Tailwind, GPT-4o-mini, Typescript
  • add multiple commands like send, buy, swap, create_token, check_balance, get_address, transaction_status, recent_transaction
  • send: send SOL to another wallet
  • create_token: create a token using token 22 program
  • check_balance: check the balance of the wallet
  • get_address: get the wallet address
  • transaction_status: get the status of the last transaction
  • recent_transaction: get the last 5 transactions

Transaction executed by agent

Example transaction:

Prompt Used

send 0.1 SOL to Ahafvp8nc3PXVwRMjgwhH7BYAyATKrGy38rvZ2AjduFg
Create Token Named GOKU and assume other details

Additional Notes

Limitations

  • The wallet-gpt doesn't support buy and swap commands.
  • I'm using GPT-4o-mini free tier, so the tokens are limited.

Extra for Testing

Checklist

  • I have tested these changes locally
  • I have updated the documentation
  • I have added a transaction link
  • I have added the prompt used to test it

@user-64bit
Copy link
Author

Hey @thearyanag 👋

Can you look into this and give some feedback?
Demo Video
Live Link

@michaelessiet
Copy link
Collaborator

Hi @user-64bit, your PR isn't making use of the Solana Agent Kit. Please can you rework it to utilize the Solana Agent Kit to carry out its actions

@user-64bit
Copy link
Author

Hi @user-64bit, your PR isn't making use of the Solana Agent Kit. Please can you rework it to utilize the Solana Agent Kit to carry out its actions

I'm on it. 🙂

@user-64bit
Copy link
Author

Hey @michaelessiet
sorry for the delay. (my laptop wasn't supporting my dev process 😓 )
Please review and tell me if i need to change anything here. 🙂

@user-64bit
Copy link
Author

off topic but this solana-agent-kit is really amazing. my token creation function is literally reduce to 5 lines of code.

@user-64bit
Copy link
Author

Hey @michaelessiet 👋
Pinging you in case you might miss my last message. 😅
Can you please review the changes and tell me if there is anything to change?

@thearyanag
Copy link
Member

hey @user-64bit - was just going over the PR, but I was unable to find direct integration of all supported wallet actions, instead there are only a few static methods

switch (action) {
     case "send":
       response = await handleSendCommand(data);
       return response;
     case "buy":
       response = await handleBuyCommand();
       return response;
     case "swap":
       response = await handleSwapCommand();
       return response;
     case "create_token":
       response = await handleCreateTokenCommand(data);
       return response;
     case "check_balance":
       response = await handleCheckBalanceCommand(publicKey);
       return response;
     case "get_address":
       response = await handleGetAddressCommand(publicKey);
       return response;
     case "transaction_status":
       response = await handleTransactionStatusCommand(publicKey, connection);
       return response;
     case "recent_transaction":
       response = await handleRecentTransactionCommand(publicKey, connection);
       return response;
     default:
       response = {
         message: data.message,
         status: "error",
       };
       return response;
   }
 }

@user-64bit
Copy link
Author

hey @user-64bit - was just going over the PR, but I was unable to find direct integration of all supported wallet actions, instead there are only a few static methods

switch (action) {
     case "send":
       response = await handleSendCommand(data);
       return response;
     case "buy":
       response = await handleBuyCommand();
       return response;
     case "swap":
       response = await handleSwapCommand();
       return response;
     case "create_token":
       response = await handleCreateTokenCommand(data);
       return response;
     case "check_balance":
       response = await handleCheckBalanceCommand(publicKey);
       return response;
     case "get_address":
       response = await handleGetAddressCommand(publicKey);
       return response;
     case "transaction_status":
       response = await handleTransactionStatusCommand(publicKey, connection);
       return response;
     case "recent_transaction":
       response = await handleRecentTransactionCommand(publicKey, connection);
       return response;
     default:
       response = {
         message: data.message,
         status: "error",
       };
       return response;
   }
 }

@thearyanag
each handle function uses related action from solana-agent-kit.
for example for handleSendCommand, it uses agent.transfer().
something like

const signature = await agent.transfer(
      new PublicKey(toPublicKey),
      parsedAmount,
    );

handleSendCommand

@user-64bit
Copy link
Author

Hello @thearyanag @michaelessiet 👋

Can you please guide me if there is any missing in this PR?
I would like to work on missing things. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example Request: Solana GPT Wallet
3 participants