Solana Wallet

Guide to use superteam earn tool on your AI agent using Vity Toolkit

A Solana wallet is a digital account that allows users to store, send, receive, and use SOL cryptocurrency on the Solana blockchain.

Quick Start

1

Install the package.

npm install vity-toolkit langchain @langchain/openai
2

Initialize Vity Toolkit and Langchain.

import { ChatOpenAI } from "@langchain/openai";
import { App, LangchainToolkit } from "vity-toolkit";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

const llm = new ChatOpenAI({ model: "gpt-4o" });
const toolKit = new LangchainToolkit({
    userPrivateKey: "<private_key>",
});
3

Add the tool.

const tools = toolKit.getTools({ apps: [App.SOLANA_WALLET] });
4

Define the Agent.

const prompt = ChatPromptTemplate.fromMessages([
  ["system", "You are a helpful assistant"],
  ["placeholder", "{chat_history}"],
  ["human", "{input}"],
  ["placeholder", "{agent_scratchpad}"],
]);

const agent = await createOpenAIFunctionsAgent({
    llm,
    tools,
    prompt,
});

const agentExecutor = new AgentExecutor({ agent, tools, verbose: true });
5

Execute the Agent.

const response = await agentExecutor.invoke({ input: "Create a Solana Wallet and give me it's public key. Also tell me it's balance." });
console.log(response);

Supported Actions

Action
Description
Action.SOLANA_WALLET_GENERATE_KEYPAIR

Generate a new Solana wallet keypair.

Action.SOLANA_WALLET_GET_BALANCE

Retrieve the balance of a Solana account.

Action.SOLANA_WALLET_GET_MY_PUBLIC_KEY

Get the public key of the current user who is using the Vity Toolkit.

Action.SOLANA_WALLET_TRANSFER

Transfer Solana tokens like SOL, USDC, BONK, etc. to another account on any network.

Last updated