Skip to content

FuelLabs/account-notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Account Notifier

This is a Vercel function that listens for Alchemy's Address Activity Webhook to create notifications in a Slack channel.

This webhook tracks the account activity events of an array of addresses, these should be set in both the webhook and Alchemy. Additional to the addresses list, a same length array of names must be provided.

Index:

  1. Setting up local environment
  2. Alchemy webhook configuration
  3. Slack bot configuration
  4. Deployment
  5. Contributing

Local Environment

Requirements

  • Node.js (v18 or later recommended)
  • npm (v6 or later recommended)
  • Vercel CLI (v23 or later recommended)
  • ngrok

Setup

  1. Clone the repository:

    git clone https://github.com/FuelLabs/account-notifier.git
    
  2. Navigate into the project directory:

    cd account-notifier
    
  3. Install the dependencies:

    pnpm install
    

Local Development

Create the env file and fill the required vars

cp .env.example > .env

To start the local development server, run:

vercel dev

This starts the server on localhost:3000.

Testing

Local Host

Use the following request to test the code.

curl --location 'localhost:3000/api' \
--header 'Content-Type: text/plain' \
--data '{
  "webhookId": "wh_foo",
  "id": "fooid_foobody",
  "createdAt": "2023-11-03T16:06:02.931Z",
  "type": "ADDRESS_ACTIVITY",
  "event": {
    "network": "ETH_MAINNET",
    "activity": [
      {
        "fromAddress": $FROM,
        "toAddress": $TO,
        "blockNum": "0x11a9c46",
        "hash": "0xabcd...",
        "value": 420,
        "asset": "USDC",
        "category": "token",
        "rawContract": {
          "rawValue": "0x000000000000000000000000000000000000000000000000000000039f712f63",
          "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
          "decimals": 6
        },
        "log": {}
      }
    ]
  }
}'

To expose your local server to the internet for testing with external services, use ngrok. First, install ngrok globally:

npm install -g ngrok

Then, in a separate terminal window, run:

ngrok http 3000

ngrok will provide a URL that you can use to access your local server from the internet.

To test your serverless functions, you can make POST requests to http://localhost:3000/api/handler (or the corresponding ngrok URL).

Check this guide to get further information.

Webhook Configuration

This notifier uses the Alchemy Address Activity Webhook.

Please visit this guide to see how to setup a new webhook. Consider using the webhook api to quickly create the webhooks for the array of addresses in just one HTTP request.

Slack Configuration

Visit this guide to get your SLACK_BOT_TOKEN.

To find the SLACK_CHANNEL_ID open slack in the browser and extract the URL segment that start with C and letters.

  https://app.slack.com/client/T_____/C_____

Deployment

To deploy your project to Vercel, run:

vercel

This command builds and deploys your project, and provides a live URL where you can access it. Use that URL in your Alchemy dashboard.

Contributing

If you wish to contribute to this project, please first discuss the change you wish to make via issue, before sending a pull request.

todo

  • [] add signature verification. See more here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published