Skip to content

Farcaster Moxie Alert Bot that posts messages about on-chain Moxie buy/sell events

License

Notifications You must be signed in to change notification settings

anastasiarods/moxie-alerts-bot

Repository files navigation

Farcaster bot for on-chain alerts

Simple open-source bot that monitors on-chain events in real-time and posts decoded messages to Farcaster. Key features:

  • Needs only an RPC URL for real-time monitoring and transaction decoding
  • Uses Airstack API to get Farcaster user's data (this API is free if you have an Airstack Fan Token)
  • 0 dependencies on any external storage

Step 0: Prerequisites

  • An installed Bun (see installation guide here)
  • An Etherscan(Basescan) account (sign up here)
  • A Farcaster account (can be yours or a separate one for your bot)
  • An Airstack API key (sing up here)
  • An RPC Url that supports eht_subsribe method, for example Tenderly or Alchemy.

Step 1: Clone the Repository

Clone the Bot repository and install project dependencies:

git clone https://github.com/anastasiarods/moxie-alerts-bot
cd moxie-alerts-bot
bun i

Step 2: Add Etherscan, Airstack API keys, and RPC URL

Copy and rename the .env.example file to .env, then paste API keys into the AIRSTACK_API_KEY and ETHERSCAN_API_KEY variables.

cp .env.example .env
vim .env

We use Airstack to fetch Farcaster user info based on the wallet address and Etherscan API key (from the free plan) to fetch contract ABIs and avoid hitting rate limits. The Etherscan API could be optional if the transactions you are interested in do not interact with many contracts.

Add an RPC URL that supports the eth_subscribe method to the WS_RPC_URL variable. Note that the WS_RPC_URL string must start with ws://. We use WS_RPC_URL to monitor new transactions based on conditions and also to decode transactions.

Step 3: Create a Farcaster Account Key or Signer (manual method)

A Farcaster signer is a separate Ed25519 public and private key pair connected to your Farcaster account that you need for posting messages on your behalf. To connect the key pair, you have to send a transaction from your Farcaster wallet to the Key Registry Farcaster smart contract. At the moment of writing this guide, there was no simple way to create and connect the signer without using 3rd party APIs. So we made a script to generate the required transaction, and to run it you need to do the following:

  1. Fund your Farcaster custody wallet on Optimism to cover gas fees:: You need some ETH on the Optimism chain to pay for the gas. A 1 dollar or less would be enough. Click on the 3 dots near your profile, press "About," and there you will find your custody address.
  2. Get your Farcaster recovery phrase and FID: On your phone, go to settings -> advanced -> recovery phrase, and write this recovery phrase into the MNEMONIC variable in the scripts/create-signer.ts file. Also paste your bot's FID into the FID variable.
  3. Run the script: Run the following command bun run scripts/create-signer.ts. The result of this script will be an Optimism transaction like this, and a public and private key printed in the console. Do not share the private key.
  4. Add env variables: Add the private key generated from the script and the bot's account FID into the SIGNER_PRIVATE_KEY and ACCOUNT_FID variables.

Step 4: Start the Bot

Use the following command to start bot locally:

bun run src/index.ts

Step 5: Check the guide to learn how it works and modify it

The guide describes all components of the bot and how to modify it to monitor the different EVM contacts.

Feedback

Let me know on Farcaster (@nastya) if you encounter any problems or have any questions, I'd love to help you!

About

Farcaster Moxie Alert Bot that posts messages about on-chain Moxie buy/sell events

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published