This project demonstrates how to publish Farcaster casts using Neynar with a Node.js & TypeScript Express server. It provides a /cast
endpoint to which you can POST a message to be published as a cast on Warpcast.
- Neynar API Key:
You need an API key from Neynar to authenticate your requests. Place it in the.env
file. - Approved Signer:
You need a valid signer that has been approved on-chain. Neynar provides tools to get a signer and instructions to approve it.
For more info on how to obtain theSIGNER_UUID
, see the Neynar documentation.
-
Clone the Repository or Copy Files
git clone https://github.com/abraham-ai/warpcast-bot cd warpcast-bot
-
Install Dependencies
npm install
-
Configure Environment Variables
Create a.env
file in the project root with the following:NEYNAR_API_KEY=your_neynar_api_key_here SIGNER_UUID=your_signer_uuid_here PORT=3000
Replace
your_neynar_api_key_here
andyour_signer_uuid_here
with your actual values.NEYNAR_API_KEY
: Your Neynar API key.SIGNER_UUID
: The UUID of your approved Farcaster signer.PORT
is optional (defaults to3000
if not set).
-
Build the Project
Compile the TypeScript code into JavaScript:npm run build
This will create a
dist
directory with compiled.js
files. -
Run the Server
Once built, start the server:npm start
The server will run at
http://localhost:3000
(or the port you specified).
Send a POST request to /cast
with a JSON body containing the text
field:
curl -X POST http://localhost:3000/cast \
-H "Content-Type: application/json" \
-d '{"text":"Hello Farcaster!"}'
If successful, you’ll receive:
{ "message": "Cast submitted successfully" }
To include frames (e.g., images, NFTs, links), add an embeds
array with URLs:
curl -X POST http://localhost:3000/cast \
-H "Content-Type: application/json" \
-d '{"text":"A mesmerizing journey through an ever-evolving mandelbrot set where consciousness itself appears to fragment and replicate, with each iteration revealing new layers of geometric complexity and mathematical beauty that mirrors the depths of human awareness.", "embeds":["https://abraham.ai/frames/674a1f237d889a0d04a06fd8"]}'
If successful:
{ "message": "Cast with frames submitted successfully" }
Farcaster clients will attempt to render the provided URL as a rich embed.
If you prefer hot-reloading while developing, run:
npm run dev
This uses nodemon
and ts-node
to automatically restart the server when you make changes to .ts
files. No need to rebuild every time.