The Givback Calculation Service is a backend service that calculates GIV tokens to be distributed to donors based on their donations. It integrates with various blockchain networks and services to track donations and calculate rewards.
- Calculates GIV token rewards for donors
- Integrates with multiple blockchain networks (Mainnet, xDai, Polygon zkEVM)
- Supports multiple donation tracking methods
- Provides API endpoints for reward calculation and verification
- Integrates with Giveth.io and Giveth Economy subgraph
- Production: https://givback.giveth.io
- Staging: https://givback-staging.giveth.io
graph TD
A[Donor] -->|Donates| B[Blockchain Networks]
B -->|Track Donations| C[Givback Calculation Service]
C -->|Calculate Rewards| D[Giveth Economy]
C -->|Store Data| E[IPFS via Pinata]
C -->|Verify Rewards| F[Verification Service]
- TypeScript/Node.js
- Express.js
- Ethers.js
- Uniswap V3 SDK
- GraphQL
- Docker
- IPFS (via Pinata)
- Donations are tracked across multiple blockchain networks
- Service calculates GIV rewards based on donation amounts and conditions
- Rewards are verified and stored
- Data is made available through API endpoints
- Node.js (v14 or higher)
- Docker and Docker Compose
- Access to blockchain nodes (Mainnet, xDai, Polygon zkEVM)
- Pinata API credentials
- Clone the repository:
git clone https://github.com/giveth/givback-calculation.git
cd givback-calculation
- Install dependencies:
npm install
- Copy environment file:
cp .env.example .env
- Configure environment variables in
.env
Required environment variables:
GIVETHIO_BASE_URL
: Giveth.io API base URLTRACE_BASE_URL
: Feathers API base URLMAINNET_NODE_URL
: Ethereum Mainnet node URLZKEVM_NODE_HTTP_URL
: Polygon zkEVM node URLXDAI_NODE_HTTP_URL
: xDai node URLPINATA_API_KEY
: Pinata API keyPINATA_SECRET_API_KEY
: Pinata secret API keyGIV_ECONOMY_SUBGRAPH_URL
: Giveth Economy subgraph URLREFERRAL_SHARE_PERCENTAGE
: Referral share percentage
Development mode:
npm start
Production mode:
docker-compose -f docker-compose-production.yml up -d
Currently, the project does not have automated tests set up. Manual testing can be done through the API endpoints.
- Calculate rewards for a specific donation
- Verify reward calculations
- Update reward distribution parameters
- Production: Deployed on production servers
- Staging: Deployed on staging servers for testing
- Build the Docker image:
docker build -t ghcr.io/giveth/givback-calculation:latest .
- Deploy using Docker Compose:
docker-compose -f docker-compose-production.yml up -d
The project uses GitHub Actions for CI/CD. Deployment is automated through the GitHub workflow.
-
Connection issues with blockchain nodes
- Solution: Verify node URLs and network connectivity
-
API rate limiting
- Solution: Implement rate limiting and retry mechanisms
-
Reward calculation discrepancies
- Solution: Verify input parameters and calculation logic
- Access logs through Docker:
docker-compose -f docker-compose-production.yml logs -f
- Enable debug mode by setting appropriate environment variables
This project is licensed under the ISC License - see the LICENSE file for details.