Keypair
Here’s how to initialize the agent with a keypair wallet:
Copy
import { PingAgentKit, createVercelAITools, KeypairWallet } from "Ping-agent-kit";
import TokenPlugin from "@ping-agent-kit/plugin-token";
import NFTPlugin from "@ping-agent-kit/plugin-nft";
import DefiPlugin from "@ping-agent-kit/plugin-defi";
import MiscPlugin from "@ping-agent-kit/plugin-misc";
import BlinksPlugin from "@ping-agent-kit/plugin-blinks";
import { Keypair } from "@ping/web3.js";
import bs58 from "bs58";
// Create a keypair from a private key
const keyPair = Keypair.fromSecretKey(bs58.decode("YOUR_SECRET_KEY"));
const wallet = new KeypairWallet(keyPair);
// Initialize with wallet and optional RPC URL
const agent = new PingAgentKit(
wallet,
"YOUR_RPC_URL",
{
OPENAI_API_KEY: "YOUR_OPENAI_API_KEY",
}
)
.use(TokenPlugin)
.use(NFTPlugin)
.use(DefiPlugin)
.use(MiscPlugin)
.use(BlinksPlugin);
// Create Vercel AI tools (or use createLangchainTools for LangChain)
const tools = createVercelAITools(agent, agent.actions);
Last updated