Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: token issuance trigger part 2 #321

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/alchemy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
gaboesquivel marked this conversation as resolved.
Show resolved Hide resolved


## Dependencies

Expand Down
7 changes: 6 additions & 1 deletion apps/alchemy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "alchemy-hooks",
"module": "src/index.ts",
"type": "module",
"scripts": {
"push": "bun src/index.ts"
},
"devDependencies": {
"@types/bun": "latest"
},
Expand All @@ -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"
}
}
24 changes: 24 additions & 0 deletions apps/alchemy/src/config.ts
Original file line number Diff line number Diff line change
@@ -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,
}
22 changes: 10 additions & 12 deletions apps/alchemy/src/index.ts
Original file line number Diff line number Diff line change
@@ -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.'
)
}

Expand Down
Empty file added apps/indexer/.debug
Empty file.
15 changes: 15 additions & 0 deletions apps/indexer/README.md
Original file line number Diff line number Diff line change
@@ -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.
gaboesquivel marked this conversation as resolved.
Show resolved Hide resolved

## Getting Started§
gaboesquivel marked this conversation as resolved.
Show resolved Hide resolved

```bash
# Copy environment variables. Put your dfuse credentials on it
cp .env-sample .env
Expand Down
Binary file modified bun.lockb
Binary file not shown.
Loading