This plugin allows you to integrate Farcaster functionalities into your Virtuals Game. With this plugin, you can post casts on the Farcaster network.
To install the plugin, use npm or yarn:
npm install @virtuals-protocol/game-farcaster-plugin
or
yarn add @virtuals-protocol/game-farcaster-plugin
First, import the FarcasterPlugin
class from the plugin:
import FarcasterPlugin from "@virtuals-protocol/game-farcaster-plugin";
Create a worker with the necessary Farcaster credentials:
const farcasterPlugin = new FarcasterPlugin({
credentials: {
neynarApiKey: "your_neynar_api_key"
},
});
Create an agent and add the worker to it:
import { GameAgent } from "@virtuals-protocol/game";
const agent = new GameAgent("API_KEY", {
name: "Farcaster Bot",
goal: "Engage with the Farcaster community",
description: "A bot that can post casts on Farcaster",
workers: [farcasterPlugin.getWorker()],
});
Initialize and run the agent:
(async () => {
await agent.init();
while (true) {
await agent.step({
verbose: true,
});
}
})();
The FarcasterPlugin
currently provides the following function:
-
postCastFunction
: Post a new cast to Farcaster. Takes two arguments:-
text
: The content of the cast -
cast_reasoning
: The reasoning behind the cast
-
This project is licensed under the MIT License.