-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
63 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,54 @@ | ||
# Wallet Alert Service | ||
|
||
|
||
# Custom Alerts for Wallet Activities | ||
|
||
|
||
|
||
This project allows users to set up personalized alerts for wallet activities like large token transfers, NFT mints, or specific on-chain events. | ||
|
||
|
||
A Go-based microservice that monitors Ethereum wallet activities and sends customized alerts based on user preferences. | ||
|
||
## Features | ||
|
||
|
||
|
||
- Personalized alerts for various wallet activities | ||
- **Real-time Transaction Monitoring** | ||
- Listens to Ethereum mainnet transactions | ||
- Detects large token transfers (> 1 ETH) | ||
- Identifies NFT transfers for popular collections (BAYC, Moonbirds) | ||
|
||
- Notifications via email | ||
- **Customizable User Alerts** | ||
- Email notifications via SendGrid | ||
- Configurable alert thresholds | ||
- Per-wallet notification preferences | ||
|
||
- Efficient filtering and indexing of on-chain events | ||
- **Event Types** | ||
- Large transfers (> 1 ETH) | ||
- NFT transfers | ||
- Custom threshold alerts | ||
|
||
- NFT transfer detection | ||
## Architecture | ||
|
||
### Core Components | ||
|
||
## Technical Overview | ||
- **Event Detection**: [`nfts.NFTDetector`](nft/nftdetector.go) for NFT transfers | ||
- **Notification Service**: [`services.EmailNotification`](services/email_notifier.go) for sending alerts | ||
- **Data Storage**: GORM-based PostgreSQL integration | ||
- **Repository Layer**: | ||
- [`EventRepository`](repository/event_repository.go) for event storage | ||
- [`UserPreferenceRepository`](repository/user_preference.go) for user preferences | ||
|
||
### Models | ||
|
||
Built with Go, this microservice connects to the Ethereum network, listens to events, indexes them based on user preferences, and triggers alerts accordingly. | ||
|
||
|
||
- [`Event`](models/event.go): Stores transaction details and event types | ||
- [`UserPreference`](models/models.go): Manages user notification preferences | ||
|
||
## Installation | ||
|
||
1. **Clone the repository**: | ||
|
||
1. **Clone the repository**: | ||
git clone https://github.com/Jetlum/WalletAlertService.git | ||
|
||
```sh | ||
git clone https://github.com/Jetlum/WalletAlertServicee.git | ||
2. **Navigate to the project directory**: | ||
```sh | ||
|
||
cd WalletAlertService | ||
|
||
3. **Install dependencies**: | ||
```sh | ||
|
||
go mod download | ||
|
||
## Configuration | ||
|
||
Create a `config.yaml` file in the root directory with the following content: | ||
|
@@ -57,46 +62,41 @@ Create a `config.yaml` file in the root directory with the following content: | |
|
||
## Usage | ||
|
||
|
||
|
||
1. **Configure the Ethereum client**: | ||
|
||
```sh | ||
client, err := ethclient.Dial("wss://mainnet.infura.io/ws/v3/YOUR_INFURA_PROJECT_ID") | ||
go run main.go | ||
|
||
2. **Configure user preferences** | ||
|
||
userPreference := &models.UserPreference{ | ||
UserID: "[email protected]", | ||
WalletAddress: "0x...", | ||
MinEtherValue: "1000000000000000000", // 1 ETH | ||
TrackNFTs: true, | ||
EmailNotification: true | ||
}) | ||
userPreference := &models.UserPreference{ | ||
UserID: "[email protected]", | ||
WalletAddress: "0x...", | ||
MinEtherValue: "1000000000000000000", // 1 ETH | ||
TrackNFTs: true, | ||
EmailNotification: true | ||
} | ||
|
||
3. **Run the application**: | ||
```sh | ||
go run main.go | ||
## Testing | ||
|
||
1. **Run all tests**: | ||
|
||
```sh | ||
go test ./... -v | ||
|
||
2. **Run specific tests**: | ||
|
||
```sh | ||
go test -v ./services/... // Test notification services | ||
go test -v ./repository/... // Test repositories | ||
|
||
## Key Components | ||
|
||
**NFT Detection**: | ||
|
||
Pre-configured list of popular NFT contract addresses | ||
Extensible for adding new collections | ||
Transaction Processing: | ||
|
||
**Real-time block monitoring**: | ||
**Transaction Processing**: | ||
|
||
Real-time block monitoring | ||
Transaction filtering and categorization | ||
Event creation and storage | ||
|
||
|
@@ -115,4 +115,22 @@ Project Structure | |
├── nft/ # NFT detection logic | ||
├── repository/ # Data access layer | ||
├── services/ # Business logic and notifications | ||
└── mock/ # Test mocks | ||
└── mock/ # Test mocks | ||
|
||
## Testing Environment | ||
The project includes a robust testing setup: | ||
|
||
Unit Tests: Testing individual components | ||
Mock Implementations: For external services and database | ||
Integration Tests: Testing component interactions | ||
|
||
Set test environment: | ||
|
||
export GO_ENV=test | ||
|
||
## Dependencies | ||
|
||
go-ethereum: Ethereum client | ||
sendgrid-go: Email notifications | ||
gorm: Database ORM | ||
viper: Configuration management |