A Go-based microservice that monitors Ethereum wallet activities and cryptocurrency prices, sending customized alerts based on user preferences.
-
Real-time Transaction Monitoring
- Listens to Ethereum mainnet transactions
- Detects large token transfers (> 1 ETH)
- Identifies NFT transfers for popular collections (BAYC, Moonbirds)
-
Cryptocurrency Price Alerts
- Real-time price monitoring via CoinGecko API
- Support for multiple cryptocurrencies (BTC, ETH)
- Customizable price thresholds
- Upper and lower bound price alerts
-
Customizable User Alerts
- Email notifications via SendGrid
- Configurable alert thresholds
- Per-wallet notification preferences
- Price alert preferences
- Event Detection:
nfts.NFTDetector
for NFT transfers - Price Monitoring:
services.PriceMonitor
for cryptocurrency prices - Alert Services:
services.PriceAlertService
for price alertsservices.EmailNotification
for notifications
- Data Storage: GORM-based PostgreSQL integration
- Repository Layer:
EventRepository
for event storageUserPreferenceRepository
for user preferencesPriceAlertRepository
for price alerts
- Mock Layer:
mock
package for testing with mock implementations
Event
: Stores transaction details and event typesUserPreference
: Manages user notification preferencesPriceAlert
: Stores cryptocurrency price alert settings
-
Clone the repository:
git clone https://github.com/Jetlum/WalletAlertService.git
-
Navigate to the project directory:
cd WalletAlertService
-
Install dependencies:
go mod download
Create a config.yaml
file in the root directory with the following content:
infura:
project_id: "YOUR_INFURA_PROJECT_ID"
database:
url: "postgresql://username:password@localhost:5432/dbname"
sendgrid:
api_key: "YOUR_SENDGRID_API_KEY"
coingecko:
api_key: "YOUR_COINGECKO_API_KEY"
price_check_interval: 1 # Interval in minutes for price checking
-
Configure the Ethereum client:
go run main.go
-
Configure user preferences
// Transaction alerts userPreference := &models.UserPreference{ UserID: "user@example.com", WalletAddress: "0x...", MinEtherValue: "1000000000000000000", // 1 ETH TrackNFTs: true, EmailNotification: true, } // Price alerts priceAlert := &models.PriceAlert{ UserID: "user@example.com", CryptocurrencyID: "BTC", ThresholdPrice: "50000.00", IsUpperBound: true, EmailNotification: true, }
-
Run all tests:
go test ./... -v
-
Run specific tests:
go test -v ./services/... // Test notification services go test -v ./repository/... // Test repositories
Project Structure
├── config/ # Configuration management
├── database/ # Database initialization and connection
├── models/ # Data models and validation
├── nft/ # NFT detection logic
├── repository/ # Data access layer
├── services/ # Business logic and notifications
├── mock/ # Mock implementations for testing
└── main.go # Application entry point
NFT Detection:
Pre-configured list of popular NFT contract addresses
Extensible for adding new collections
Transaction Processing:
Real-time block monitoring
Transaction filtering and categorization
Event creation and storage
Price Monitoring:
Real-time cryptocurrency price tracking
Configurable check intervals
Support for multiple cryptocurrencies
Threshold-based alerts
Notification System
Notification System:
Email notifications via SendGrid
User preference-based filtering
Customizable notification templates
Support for both transaction and price alerts
Project Structure
├── config/ # Configuration management
├── database/ # Database initialization and connection
├── models/ # Data models
├── nft/ # NFT detection logic
├── repository/ # Data access layer
├── services/ # Business logic and notifications
└── mock/ # Test mocks
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
go-ethereum: Ethereum client
sendgrid-go: Email notifications
gorm: Database ORM
viper: Configuration management
coingecko-api: CoinGecko API client