Skip to content

🤖 A Twitter bot that posts daily update about the status of OFAC-compliant blocks on Ethereum

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

0xYYY/mev-watch-bot

Repository files navigation

🤖 MEV Watch Bot

Post daily update of Ethereum OFAC-compliant block rate on Twitter (MEV Watch Bot). Screenshot and statistics are obtained from MEV Watch.

Requirements

Service/API used in this bot.

Google Cloud

  1. Create a Google Cloud account and a project.
  2. Set up a Scheduler for the daily cron job.
  3. Set up a Pub/Sub topic.
  4. Install the gcloud command line tool.

Architecture

The cron job will publish an event to the topic daily, triggering the bot function to execute its logic to get screenshot of and request historical data from the MEV Watch website, then upload the screenshot and compose a tweet to post on Twitter.

flowchart LR
A("Daily Cron Jub<br>(Cloud Scheduler)")
B("Topic<br>(Cloud Pub/Sub)")
C("Bot Script<br>(Cloud Functions)")
A -- publish --> B
C -- subscribe --> B
Loading

Twitter

  1. Create a developer account and an app. Then put the secret tokens in .env. (Refer to .env.example. Also, recommend setting up direnv to auto-load .env when entering project directory.)
  2. Configure the app's "User authentication settings" to have "Read and write" app permissions. As for "Callback URI" and "Website URL" in the "App Info" section, we can set it to anything (e.g. just https://twitter.com).
  3. Apply for elevated access since some of the APIs used here need it.
  4. Create another Twitter account for the bot. (To obtian an email account for this, I would recommend Proton Mail, since they doesn't ask for personal info when createing an account.)
  5. Optionally set up automated account label for the bot.

One-Time Authorization for the Bot Account

After setting up the accounts, we'll need gain permission to tweet on behalf of the bot account.

  1. Log in to the bot account in the browser.
  2. Run yarn auth.
  3. Go to the link shown in the console with the same browser as in Step 1.
  4. Copy the PIN code and input to the console.

The secret tokens for the bot account will then be appended to .env. Store them in Google Cloud Secret Manager.

Deploy

  1. yarn lint: code formatting and linting.
  2. yarn deploy: build and deploy the bot.
  3. yarn trigger: manually trigger the bot function (often used for testing).

Note The first time deploying the bot to Google Cloud, some warnings and errors will pop up asking for permissions, e.g. granting default service account access to Secret Manager. Simply follow the hints and set up the required permissions to proceed.

Contribution

Absolutely welcome. Also feel free to reach out to discuss the project or anything else!

License

Dual licensed under either MIT License or Apache License, Version 2.0.

About

🤖 A Twitter bot that posts daily update about the status of OFAC-compliant blocks on Ethereum

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks