This toolkit contains tools that enable an LLM agent to interact with Farcaster using Neynar's API. The toolkit provides a wrapper around the Neynar API, allowing agents to interact with Farcaster and perform actions like posting casts.
- Farcaster Account
- Neynar API Key
- Neynar Managed Signer ID
- OpenAI API Key
- Node.js 18 or higher
npm install @coinbase/farcaster-langchain
Set the following environment variables:
export CDP_API_KEY_NAME=<your-api-key-name>
export CDP_API_KEY_PRIVATE_KEY=$'<your-private-key>'
export AGENT_FID=<your-farcaster-fid>
export NEYNAR_API_KEY=<your-neynar-api-key>
export NEYNAR_MANAGED_SIGNER=<your-neynar-managed-signer>
export OPENAI_API_KEY=<your-openai-api-key>
export NETWORK_ID=base-sepolia # Optional: Defaults to base-sepolia
import { FarcasterToolkit } from "@coinbase/farcaster-langchain";
import { FarcasterAgentkit } from "@coinbase/cdp-agentkit-core";
// Initialize LLM
const llm = new ChatOpenAI({ model: "gpt-4o-mini" });
// Farcaster Agentkit
const farcasterAgentkit = new FarcasterAgentkit();
// Farcaster Toolkit
const farcasterToolkit = new FarcasterToolkit(farcasterAgentkit);
// Get available Farcaster tools
const tools = farcasterToolkit.getTools();
The toolkit provides the following tools:
- farcaster_account_details - Retrieve account details for the agent's Farcaster account
- farcaster_post_cast - Post a cast to Farcaster
Check out farcaster-langchain/examples for sample implementations!
- Chatbot Typescript: Simple example of a Node.js Chatbot that can post casts to Farcaster.