Langchain
Transfer tokens on Solana with the help of Langchain and Vity Toolkit in less than 30 lines
Transfer tokens to another wallet on Solana
2
Initialize Vity Toolkit and Langchain.
import { ChatOpenAI } from "@langchain/openai";
import { Action, 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
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 });
Last updated
