Skip to content

elizaos-plugins/plugin-farcaster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

@elizaos/plugin-farcaster

A multi-language Farcaster plugin for elizaOS, providing full integration with the Farcaster decentralized social network via the Neynar API.

Languages

This plugin is implemented in three languages with full feature parity:

  • TypeScript - Primary implementation for Node.js and browser
  • Python - Python implementation for ML/AI pipelines
  • Rust - High-performance implementation with WASM support

Features

  • Cast Management: Send casts, reply to casts, and manage your timeline
  • Profile Management: Fetch and cache user profiles
  • Mentions & Notifications: Monitor and respond to mentions
  • Timeline Provider: Access your Farcaster feed
  • Thread Support: Navigate and respond within cast threads
  • Embed Processing: Handle images, videos, and embedded casts
  • Webhook Support: Real-time updates via webhooks
  • Polling Mode: Periodic fetching for simple deployments

Installation

TypeScript/Node.js

npm install @elizaos/plugin-farcaster
# or
bun add @elizaos/plugin-farcaster

Python

pip install elizaos-plugin-farcaster

Rust

Add to your Cargo.toml:

[dependencies]
elizaos-plugin-farcaster = "1.0"

Configuration

The plugin requires the following environment variables:

Variable Required Description
FARCASTER_FID Yes Your Farcaster ID (FID)
FARCASTER_SIGNER_UUID Yes Neynar signer UUID for signing casts
FARCASTER_NEYNAR_API_KEY Yes Neynar API key for API access
FARCASTER_DRY_RUN No Enable dry run mode (default: false)
FARCASTER_MODE No Operation mode: 'polling' or 'webhook' (default: polling)
MAX_CAST_LENGTH No Maximum cast length (default: 320)
FARCASTER_POLL_INTERVAL No Polling interval in seconds (default: 120)
ENABLE_CAST No Enable auto-casting (default: true)
CAST_INTERVAL_MIN No Min cast interval in minutes (default: 90)
CAST_INTERVAL_MAX No Max cast interval in minutes (default: 180)

Usage

TypeScript

import farcasterPlugin from "@elizaos/plugin-farcaster";

// Register with agent runtime
const agent = new AgentRuntime({
  plugins: [farcasterPlugin],
  // ... other config
});

Python

from elizaos_plugin_farcaster import FarcasterClient, FarcasterConfig

# Load configuration from environment
config = FarcasterConfig.from_env()

# Create client
async with FarcasterClient(config) as client:
    # Send a cast
    casts = await client.send_cast("Hello from elizaOS! πŸ€–")
    print(f"Cast sent: {casts[0].hash}")

Rust

use elizaos_plugin_farcaster::{FarcasterClient, FarcasterConfig};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let config = FarcasterConfig::from_env()?;
    let client = FarcasterClient::new(config)?;

    let casts = client.send_cast("Hello from elizaOS! πŸ€–", None).await?;
    println!("Cast sent: {}", casts[0].hash);

    Ok(())
}

Actions

SEND_CAST

Posts a new cast to Farcaster.

// Triggered by messages containing: post, cast, share, announce, farcaster, post
"Please post about the new ElizaOS features on Farcaster";

REPLY_TO_CAST

Replies to an existing cast.

// Triggered by messages containing: reply, respond, answer, comment
"Reply to that cast and thank them for the feedback";

Providers

farcaster_profile

Provides the agent's Farcaster profile information for context.

farcaster_timeline

Provides the agent's recent timeline for context about recent activity.

farcaster_thread

Provides thread context for understanding conversation flow.

Development

Building

# TypeScript
bun run build

# Python
cd python && python -m build

# Rust
cd rust && cargo build --release

Testing

# All languages
bun run test

# TypeScript only
bun run test:ts

# Python only
bun run test:python

# Rust only
bun run test:rust

Linting

# TypeScript
bun run lint

# Python
bun run lint:python

# Rust
bun run lint:rust

Architecture

plugin-farcaster/
β”œβ”€β”€ typescript/          # TypeScript implementation
β”‚   β”œβ”€β”€ index.ts         # Main plugin entry
β”‚   β”œβ”€β”€ client/          # Neynar API client
β”‚   β”œβ”€β”€ services/        # Service layer
β”‚   β”œβ”€β”€ actions/         # SEND_CAST, REPLY_TO_CAST
β”‚   β”œβ”€β”€ providers/       # Context providers
β”‚   └── types/           # Type definitions
β”œβ”€β”€ python/              # Python implementation
β”‚   β”œβ”€β”€ elizaos_plugin_farcaster/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ client.py    # Neynar API client
β”‚   β”‚   β”œβ”€β”€ service.py   # Service layer
β”‚   β”‚   └── types.py     # Type definitions
β”‚   └── tests/
└── rust/                # Rust implementation
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ lib.rs       # Library entry
    β”‚   β”œβ”€β”€ client.rs    # Neynar API client
    β”‚   β”œβ”€β”€ service.rs   # Service layer
    β”‚   β”œβ”€β”€ actions/     # Action implementations
    β”‚   └── providers/   # Provider implementations
    └── tests/

API Reference

TypeScript

  • FarcasterService - Main service managing client lifecycle
  • FarcasterClient - Low-level API client
  • sendCastAction - Action for posting casts
  • replyCastAction - Action for replying to casts
  • farcasterProfileProvider - Profile context provider
  • farcasterTimelineProvider - Timeline context provider

Python

  • FarcasterService - Main service class
  • FarcasterClient - Async API client
  • FarcasterConfig - Configuration dataclass
  • SendCastAction - Cast action
  • ReplyCastAction - Reply action
  • ProfileProvider - Profile provider
  • TimelineProvider - Timeline provider

Rust

  • FarcasterService - Main service struct
  • FarcasterClient - API client
  • FarcasterConfig - Configuration struct
  • SendCastAction - Cast action
  • ReplyCastAction - Reply action
  • ProfileProvider - Profile provider
  • TimelineProvider - Timeline provider

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please ensure that any changes maintain feature parity across all three language implementations.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors