diff --git a/apps/alchemy/README.md b/apps/alchemy/README.md index 40c6c6b3..a6afb129 100644 --- a/apps/alchemy/README.md +++ b/apps/alchemy/README.md @@ -3,6 +3,10 @@ This project sets up Alchemy webhooks to listen for blockchain events. These hooks invoke Trigger.dev jobs that process the events using Viem. +## Getting Started + +This project follows the [Alchemy SDK Developer Challenge Guide](https://docs.alchemy.com/docs/sdk-developer-challenge-guide-7) to set up and configure Alchemy webhooks. The guide provides step-by-step instructions. For detailed implementation steps and best practices, refer to the guide above. + ## Dependencies diff --git a/apps/alchemy/package.json b/apps/alchemy/package.json index 1c4b90e2..1113d0ac 100644 --- a/apps/alchemy/package.json +++ b/apps/alchemy/package.json @@ -2,6 +2,9 @@ "name": "alchemy-hooks", "module": "src/index.ts", "type": "module", + "scripts": { + "push": "bun src/index.ts" + }, "devDependencies": { "@types/bun": "latest" }, @@ -10,6 +13,8 @@ }, "dependencies": { "alchemy-sdk": "^3.4.1", - "dotenv": "^16.4.5" + "dotenv": "^16.4.5", + "viem": "^2.20.0", + "zod": "^3.23.8" } } diff --git a/apps/alchemy/src/config.ts b/apps/alchemy/src/config.ts new file mode 100644 index 00000000..f7914c6f --- /dev/null +++ b/apps/alchemy/src/config.ts @@ -0,0 +1,24 @@ +import { z } from 'zod' +import { isAddress } from 'viem' +import dotenv from 'dotenv' + +dotenv.config() + +const envSchema = z.object({ + ALCHEMY_NOTIFY_TOKEN: z.string().min(1, 'Alchemy notify token is required'), + ALCHEMY_ACTIVITY_WEBHOOK_URL: z.string().url('Invalid webhook URL'), + PRESALE_ADDRESS: z.string().refine(isAddress, 'Invalid Ethereum address'), +}) + +const parsedEnv = envSchema.safeParse(process.env) +if (!parsedEnv.success) { + console.error('Environment validation failed:', parsedEnv.error.format()) + process.exit(1) +} + + +export const appConfig = { + alchemyNotifyToken: parsedEnv.data.ALCHEMY_NOTIFY_TOKEN, + alchemyActivityWebhookUrl: parsedEnv.data.ALCHEMY_ACTIVITY_WEBHOOK_URL, + presaleAddress: parsedEnv.data.PRESALE_ADDRESS, +} \ No newline at end of file diff --git a/apps/alchemy/src/index.ts b/apps/alchemy/src/index.ts index 3b4cac2f..305c01a2 100644 --- a/apps/alchemy/src/index.ts +++ b/apps/alchemy/src/index.ts @@ -1,27 +1,25 @@ -require('dotenv').config() import { Alchemy, Network, WebhookType } from 'alchemy-sdk' +import { appConfig } from './config' -// authToken is required to use Notify APIs. Found on the top right corner of -// https://dashboard.alchemy.com/notify. async function createAddressActivityNotification() { const settings = { - authToken: process.env.ALCHEMY_NOTIFY_TOKEN, - network: Network.MATIC_MAINNET, // Replace with your network. + authToken: appConfig.alchemyNotifyToken, + network: Network.MATIC_MAINNET // Replace with your network. } const alchemy = new Alchemy(settings) const addressActivityWebhook = await alchemy.notify.createWebhook( - // TO DO: You will replace this URL in Step #3 of this guide! - 'https://webhook.site/f18c0350-6479-4686-b48a-3d16aa238b7b', + appConfig.alchemyActivityWebhookUrl, WebhookType.ADDRESS_ACTIVITY, { - // use any address you want to monitor activity on! - addresses: ['0x6F76670A66e7909Af9B76f0D84E39317FCc0B2e1'], - network: Network.MATIC_MAINNET, - }, + addresses: [appConfig.presaleAddress], + network: Network.MATIC_MAINNET + } ) + console.log('Address Activity Webhook Details:') + console.log(JSON.stringify(addressActivityWebhook, null, 2)) console.log( - 'Alchemy Notify address activity notification created, go to https://dashboard.alchemy.com/notify to see details of your custom hook.', + 'Alchemy Notify address activity notification created, go to https://dashboard.alchemy.com/notify to see details of your custom hook.' ) } diff --git a/apps/indexer/.debug b/apps/indexer/.debug new file mode 100644 index 00000000..e69de29b diff --git a/apps/indexer/README.md b/apps/indexer/README.md index 52353ed1..11f536e2 100644 --- a/apps/indexer/README.md +++ b/apps/indexer/README.md @@ -1,5 +1,20 @@ # Bitlauncher Indexer +The Bitlauncher Indexer is a critical component of our blockchain data processing ecosystem. It's an advanced, high-performance system designed to efficiently capture, process, and store blockchain events in real-time. By continuously monitoring the blockchain, the indexer ensures that the Bitlauncher platform always has access to the most up-to-date and accurate on-chain data. + +Key responsibilities of the Bitlauncher Indexer include: + +- Real-time event monitoring: Continuously listens for new blocks and transactions on the blockchain. +- Smart contract interaction tracking: Indexes and processes events related to specific smart contracts. +- Token transfer tracking: Monitors and records all token transfer activities. +- Data normalization: Transforms raw blockchain data into a structured format for easy querying and analysis. +- Historical data management: Maintains a comprehensive historical record of blockchain activities. +- API integration: Provides a robust API for other components of the Bitlauncher platform to access indexed data. +- Performance optimization: Ensures high throughput and low latency in data processing and retrieval. +- Scalability: Designed to handle increasing blockchain activity and data volume. + +## Getting Started§ + ```bash # Copy environment variables. Put your dfuse credentials on it cp .env-sample .env diff --git a/bun.lockb b/bun.lockb index 04eeaf04..03a36c97 100755 Binary files a/bun.lockb and b/bun.lockb differ