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
- 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.
Clone the Bot repository and install project dependencies:
git clone https://github.com/anastasiarods/moxie-alerts-bot
cd moxie-alerts-bot
bun i
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.
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:
- 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.
- 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 thescripts/create-signer.ts
file. Also paste your bot's FID into theFID
variable. - 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. - Add env variables: Add the private key generated from the script and the bot's account FID into the
SIGNER_PRIVATE_KEY
andACCOUNT_FID
variables.
Use the following command to start bot locally:
bun run src/index.ts
The guide describes all components of the bot and how to modify it to monitor the different EVM contacts.
Let me know on Farcaster (@nastya) if you encounter any problems or have any questions, I'd love to help you!