Complete setup guide for contributors - Get NotifyChain running locally from scratch
- Prerequisites & Dependencies
- Project Structure Overview
- Quick Start
- Component-Specific Setup
- Testing & Quality Assurance
- Environment Variables
- Troubleshooting
- Development Workflows
- Contributing Guidelines
Before starting, ensure you have the following software installed on your machine:
| Tool | Minimum Version | Purpose | Installation Link |
|---|---|---|---|
| Node.js | v18+ (v20 recommended for Listener) | JavaScript runtime for listener & dashboard | nodejs.org |
| npm | v9.0.0+ | Package manager (bundled with Node.js) | Comes with Node.js |
| Rust | Latest stable | Smart contract development | rustup.rs |
| Stellar CLI | Latest | Deploy & interact with contracts | See installation |
| Git | v2.30.0+ | Version control | git-scm.com |
| SQLite | v3.35.0+ | Database for scheduled notifications | Usually pre-installed |
| Tool | Purpose | Installation Link |
|---|---|---|
| Docker Desktop | Containerized development (future) | docker.com |
| VS Code | Recommended IDE | code.visualstudio.com |
| Postman | API testing | postman.com |
NotifyChain/
├── contract/ # Soroban smart contracts (Rust)
│ ├── contracts/
│ │ └── hello-world/ # AutoShare contract
│ │ ├── src/
│ │ │ ├── base/ # Core types, errors, events
│ │ │ ├── interfaces/ # Contract interfaces
│ │ │ ├── tests/ # Contract unit tests
│ │ │ ├── lib.rs # Contract entry point
│ │ │ └── autoshare_logic.rs # Business logic
│ │ ├── Cargo.toml
│ │ └── Makefile
│ └── Cargo.toml # Workspace configuration
│
├── listener/ # Off-chain event listener (Node.js/TypeScript)
│ ├── src/
│ │ ├── api/ # REST API endpoints
│ │ ├── database/ # SQLite database layer
│ │ ├── services/ # Business logic services
│ │ │ ├── discord-notification.ts
│ │ │ ├── event-subscriber.ts
│ │ │ ├── notification-scheduler.ts
│ │ │ └── scheduled-notification-repository.ts
│ │ ├── store/ # In-memory event registry
│ │ ├── types/ # TypeScript type definitions
│ │ ├── utils/ # Helper utilities
│ │ ├── config.ts # Configuration loader
│ │ └── index.ts # Application entry point
│ ├── data/ # SQLite database files (created on first run)
│ ├── .env.example # Environment variable template
│ ├── package.json
│ ├── tsconfig.json
│ └── jest.config.js
│
├── dashboard/ # React frontend dashboard
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── pages/ # Page components
│ │ ├── services/ # API clients
│ │ ├── store/ # Zustand state management
│ │ ├── App.tsx # Root component
│ │ └── main.tsx # Application entry point
│ ├── index.html
│ ├── package.json
│ ├── vite.config.ts
│ └── tsconfig.json
│
├── Documents/
│ └── Task Bounty/ # TaskBounty contract (alternative example)
│
├── .github/
│ └── workflows/ # CI/CD pipelines
│
├── README.md # Project overview
├── CONTRIBUTING.md # Contribution guidelines
└── DEVELOPMENT.md # This file
| Directory | Purpose |
|---|---|
contract/ |
Rust-based Soroban smart contracts for blockchain deployment |
listener/ |
Node.js service that monitors blockchain events and sends notifications |
dashboard/ |
React web application for viewing events and managing subscriptions |
Documents/Task Bounty/ |
Alternative example contract demonstrating task/bounty management |
⚡ Get up and running in 5 minutes
git clone https://github.com/Core-Foundry/Notify-Chain.git
cd Notify-Chain# Install listener dependencies
cd listener
npm install
# Install dashboard dependencies
cd ../dashboard
npm install
# Return to root
cd ..cd listener
cp .env.example .env
# Edit .env with your configuration (see Environment Variables section)# From listener directory
npm run migrate# Terminal 1: Start listener service
cd listener
npm run dev
# Terminal 2: Start dashboard
cd dashboard
npm run devAccess Points:
- Listener API: http://localhost:8787
- Dashboard: http://localhost:5173
# Install Rust using rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Load Rust environment
source $HOME/.cargo/env
# Verify installation
rustc --version
cargo --versionrustup target add wasm32-unknown-unknown# Install via cargo
cargo install --locked stellar-cli --features opt
# Verify installation
stellar --versionNote: Stellar CLI installation may take 5-10 minutes.
cd contract
stellar contract buildOutput: Compiled WASM file at target/wasm32-unknown-unknown/release/hello_world.wasm
cd Documents/Task\ Bounty
stellar contract build# AutoShare contract tests
cd contract/contracts/hello-world
cargo test
# TaskBounty contract tests
cd ../../../Documents/Task\ Bounty
cargo test- Generate a test identity:
stellar keys generate test-user --network testnet- Fund your identity (get test XLM):
stellar keys fund test-user --network testnet- Deploy the contract:
cd contract/contracts/hello-world
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/hello_world.wasm \
--source test-user \
--network testnet-
Save the contract ID (output from deploy command)
-
Initialize the contract:
stellar contract invoke \
--id <CONTRACT_ID> \
--source test-user \
--network testnet \
-- \
initialize_admin \
--admin <YOUR_ADDRESS># Verify Node.js version (must be 18+)
node --version
# Verify npm version
npm --versioncd listener
npm install# Copy example environment file
cp .env.example .envEdit .env with your configuration:
# Stellar Network Configuration
STELLAR_NETWORK=testnet
STELLAR_RPC_URL=https://soroban-testnet.stellar.org:443
# Contract Addresses (JSON array)
CONTRACT_ADDRESSES=[{"address":"YOUR_CONTRACT_ID","events":["*"]}]
# Polling Configuration
POLL_INTERVAL_MS=30000
MAX_RECONNECT_ATTEMPTS=5
# API Configuration
EVENTS_API_PORT=8787
EVENTS_API_CORS_ORIGIN=http://localhost:5173
# Discord Webhook (optional)
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK
# Database Configuration
DATABASE_PATH=./data/notifications.db
# Scheduler Configuration
SCHEDULER_ENABLED=true
SCHEDULER_POLL_INTERVAL_MS=10000# Initialize SQLite database
npm run migrateWhat this does:
- Creates
./data/directory - Creates
notifications.dbSQLite database - Runs schema migrations
- Creates
scheduled_notificationsandnotification_execution_logtables
# Development mode (with auto-reload)
npm run dev
# Production mode
npm run build
npm startExpected Output:
info: Connected to SQLite database {"path":"./data/notifications.db"}
info: Database migration completed successfully
info: Notification scheduler started successfully
info: Events API server listening {"port":8787}
info: Starting event subscriber service
# Test health endpoint
curl http://localhost:8787/health
# Test events endpoint
curl http://localhost:8787/api/events
# Test scheduler stats
curl http://localhost:8787/api/schedule/stats# Verify Node.js version (must be 18+)
node --versioncd dashboard
npm install# Development mode (with hot reload)
npm run devAccess: http://localhost:5173
Expected Output:
VITE v6.3.5 ready in 450 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
npm run buildOutput: dist/ directory with optimized static files
npm run preview# Contracts: AutoShare
cd contract/contracts/hello-world
cargo test
# Contracts: TaskBounty
cd ../../../Documents/Task\ Bounty
cargo test
# Listener: All tests
cd ../../listener
npm test
# Listener: Specific test file
npm test notification-scheduler.test.ts
# Listener: With coverage
npm test -- --coverage
# Dashboard: All tests
cd ../dashboard
npm test
# Dashboard: Watch mode
npm test -- --watch# Listener: TypeScript linting
cd listener
npm run lint # (if lint script exists)
# Dashboard: ESLint
cd dashboard
npm run lint
# Auto-fix linting issues
npm run lint -- --fix# Contracts: Rust formatting
cd contract/contracts/hello-world
cargo fmt
# Listener: (Add prettier if needed)
cd ../../listener
npx prettier --write "src/**/*.ts"
# Dashboard: (Add prettier if needed)
cd ../dashboard
npx prettier --write "src/**/*.{ts,tsx}"| Variable | Required | Default | Description |
|---|---|---|---|
STELLAR_NETWORK |
No | testnet |
Stellar network (testnet, mainnet) |
STELLAR_RPC_URL |
No | https://soroban-testnet.stellar.org:443 |
Stellar RPC endpoint |
CONTRACT_ADDRESSES |
Yes | [] |
JSON array of contracts to monitor |
POLL_INTERVAL_MS |
No | 30000 |
How often to poll for events (ms) |
MAX_RECONNECT_ATTEMPTS |
No | 5 |
Max reconnection attempts |
RECONNECT_DELAY_MS |
No | 5000 |
Delay between reconnections (ms) |
EVENTS_API_PORT |
No | 8787 |
API server port |
EVENTS_API_CORS_ORIGIN |
No | http://localhost:5173 |
CORS origin |
DISCORD_WEBHOOK_URL |
No | - | Discord webhook for notifications |
DATABASE_PATH |
No | ./data/notifications.db |
SQLite database path |
SCHEDULER_ENABLED |
No | true |
Enable notification scheduler |
SCHEDULER_POLL_INTERVAL_MS |
No | 10000 |
Scheduler poll interval (ms) |
SCHEDULER_BATCH_SIZE |
No | 10 |
Notifications per batch |
[
{
"address": "CABC123...",
"events": ["*"] // or ["AutoshareCreated", "AutoshareUpdated"]
},
{
"address": "CDEF456...",
"events": ["TaskCreated", "WorkSubmitted"]
}
]Solution: Rebuild native modules
cd listener
npm rebuild sqlite3Solution: Run migrations
cd listener
npm run migrateSolution: Change port or kill existing process
# Find process using port
lsof -i :8787 # macOS/Linux
netstat -ano | findstr :8787 # Windows
# Change port in .env
EVENTS_API_PORT=8788Solution: Reinstall Stellar CLI
cargo install --locked stellar-cli --features opt --forceSolution: Add wasm32 target
rustup target add wasm32-unknown-unknownChecklist:
- Is listener running? (
curl http://localhost:8787/health) - Is CORS configured? (Check
EVENTS_API_CORS_ORIGIN) - Are contract addresses configured?
Debug Steps:
# Check listener logs
cd listener
npm run dev
# Check API directly
curl http://localhost:8787/api/events
# Check health endpoint
curl http://localhost:8787/healthSolution: Fund your test account
stellar keys fund test-user --network testnetSolution: Clean and reinstall
# Listener
cd listener
rm -rf node_modules dist
npm install
npm run build
# Dashboard
cd dashboard
rm -rf node_modules dist
npm install
npm run build- Update contract configuration:
cd listener
# Edit .env
CONTRACT_ADDRESSES=[{"address":"YOUR_CONTRACT","events":["NewEvent"]}]- Restart listener:
npm run dev- Verify event detection:
curl http://localhost:8787/api/events-
Create Discord webhook:
- Go to Discord Server → Settings → Integrations → Webhooks
- Create webhook and copy URL
-
Update listener configuration:
# Edit .env
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK- Restart listener - notifications will be sent automatically
curl -X POST http://localhost:8787/api/schedule \
-H "Content-Type: application/json" \
-d '{
"payload": {"message": "Scheduled notification"},
"notificationType": "discord",
"targetRecipient": "webhook-url",
"executeAt": "2024-12-31T12:00:00Z",
"priority": 5
}'All components support hot reload:
- Contracts: Rebuild with
stellar contract build - Listener: Automatic reload with
ts-nodein dev mode - Dashboard: Vite hot module replacement (HMR)
- Run all tests:
npm test # in listener/
npm test # in dashboard/
cargo test # in contracts/- Check linting:
npm run lint # in dashboard/
cargo fmt # in contracts/- Verify build:
npm run build # in listener/ and dashboard/
stellar contract build # in contract/-
Update documentation if adding features
-
Follow commit message convention:
feat: Add notification templating system
fix: Resolve race condition in scheduler
docs: Update development guide
test: Add tests for Discord service
- TypeScript: Follow existing patterns, use types over
any - Rust: Follow
cargo fmtandcargo clippyrecommendations - React: Use functional components with hooks
- Tests: Write tests for new features
- Comments: Document complex logic
- Fork the repository
- Create a feature branch (
feature/my-feature) - Commit changes
- Push to your fork
- Open a Pull Request
- Address review feedback
- Merge after approval
- README.md - Project overview
- LOCAL_DEVELOPMENT.md - Quick local setup
- CONTRIBUTOR_SETUP.md - Detailed contributor setup
- CONTRIBUTOR_DEVELOPMENT_WORKFLOW_GUIDE.md - Canonical contribution workflow
- docs/ - Additional architecture and API docs
- dashboard/STORYBOOK.md - Dashboard component Storybook
- listener/INSTALLATION.md - Detailed listener setup
- listener/README-SCHEDULER.md - Scheduler documentation
- listener/TEST-FIXTURE-MIGRATION-GUIDE.md - Testing guide
- Stellar Documentation
- Soroban Documentation
- Rust Documentation
- Node.js Documentation
- React Documentation
Before considering your setup complete, verify:
- Rust, Node.js, and Stellar CLI installed
- All dependencies installed (
npm installin listener/ and dashboard/) - Environment variables configured (
.envin listener/) - Database initialized (
npm run migratein listener/) - Contracts build successfully
- Listener starts without errors
- Dashboard loads at http://localhost:5173
- API health check passes (http://localhost:8787/health)
- All tests pass
You're ready to contribute to NotifyChain! 🚀
For questions or issues, please open a GitHub Issue.