Post daily update of Ethereum OFAC-compliant block rate on Twitter (MEV Watch Bot). Screenshot and statistics are obtained from MEV Watch.
Service/API used in this bot.
- Create a Google Cloud account and a project.
- Set up a Scheduler for the daily cron job.
- Set up a Pub/Sub topic.
- Install the
gcloud
command line tool.
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
- Create a developer account and an app. Then
put the secret tokens in
.env
. (Refer to.env.example
. Also, recommend setting updirenv
to auto-load.env
when entering project directory.) - 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).
- Apply for elevated access since some of the APIs used here need it.
- 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.)
- Optionally set up automated account label for the bot.
After setting up the accounts, we'll need gain permission to tweet on behalf of the bot account.
- Log in to the bot account in the browser.
- Run
yarn auth
. - Go to the link shown in the console with the same browser as in Step 1.
- 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.
yarn lint
: code formatting and linting.yarn deploy
: build and deploy the bot.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.
Absolutely welcome. Also feel free to reach out to discuss the project or anything else!
Dual licensed under either MIT License or Apache License, Version 2.0.