import { http } from "viem";
import { createWalletClient } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
import { getOnChainTools } from "@goat-sdk/adapter-langchain";
import { PEPE, USDC, erc20 } from "@goat-sdk/plugin-erc20";
import { sendETH } from "@goat-sdk/wallet-evm";
import { viem } from "@goat-sdk/wallet-viem";
import { ChatOpenAI } from "@langchain/openai";
import { createAgent } from "@langchain/classic";
// 1. Create a wallet client
const account = privateKeyToAccount(
process.env.WALLET_PRIVATE_KEY as `0x${string}`
);
const walletClient = createWalletClient({
account: account,
transport: http(process.env.RPC_PROVIDER_URL),
chain: baseSepolia,
});
// 2. Set up the tools
const tools = await getOnChainTools({
wallet: viem(walletClient),
plugins: [sendETH(), erc20({ tokens: [USDC, PEPE] })],
});
// 3. Create the agent
const model = new ChatOpenAI({
model: "gpt-4o-mini",
});
const agent = createAgent({ llm: model, tools: tools });