Farcaster Bot with Dedicated Signers
Create a Farcaster bot on Neynar in a few quick steps
Simplest way to start is to clone this git repo that has a sample bot ready to go: https://github.com/neynarxyz/farcaster-examples
In our farcaster-examples
repo, gm_bot
is an automated messaging bot designed to cast a ‘gm ’ message in Warpcast every day at a scheduled time. The bot operates continuously as long as the system remains online. It leverages Neynar API and is built using @neynar/nodejs-sdk.
Prerequisites
- Node.js: A JavaScript runtime built on Chrome’s V8 JavaScript engine. Ensure you have Node.js installed on your system.
Installation
Setting Up the Environment
Install PM2
PM2 is a process manager for Node.js applications. Install it globally using npm:
Install Project Dependencies
Navigate to the project directory and run one of the following commands to install all required dependencies:
Configure Environment Variables
- Copy the example environment file:
- Open the repo in your favorite editor and edit
.env
file to add yourNEYNAR_API_KEY
andFARCASTER_BOT_MNEMONIC
. Optionally, you can also specifyPUBLISH_CAST_TIME
andTIME_ZONE
for custom scheduling.
Generating a Signer
Before running the bot, you need to generate a signer and get it approved via an onchain transaction. To execute the transaction, you’ll need a browser extension wallet with funded roughly $2 worth of OP ETH on the Optimism mainnet. This is crucial for the bot’s operation. Run the following command in the terminal:
This command will create some logs in your terminal. We will use these logs for upcoming steps below.
Approving a signer
In order to get an approved signer you need to do an on-chain transaction on OP mainnet.
Go to Farcaster KeyGateway optimism explorer https://optimistic.etherscan.io/address/0x00000000fc56947c7e7183f8ca4b62398caadf0b#writeContract
Connect to Web3.
Remember the terminal logs we generated one of the earlier steps? You will see values for fidOwner
, keyType
, key
, metadataType
, metadata
, deadline
, sig
in your terminal logs. Navigate to addFor
function and add following values inside the respective placeholders.
Press “Write” to execute the transaction. This will create a signer for your mnemonic on the OP mainnet.
Running the Bot
Start the Bot
Launch the bot using the following command:
Verify the Process
Ensure that the bot is running correctly with:
View Logs
To check the bot’s activity logs, use:
Stopping the Bot
If you need to stop the bot, use:
License
gm_bot
is released under the MIT License. This license permits free use, modification, and distribution of the software, with the requirement that the original copyright and license notice are included in any substantial portion of the work.
FAQs/Troubleshooting
Ready to start building?
Get your subscription at neynar.com and reach out to us on Telegram with any questions!
Was this page helpful?