This project automatically rewards contributors to open source projects with tokens when their pull requests are merged to the master branch. It creates a seamless integration between GitHub, Solana blockchain, and Twitter to:
- Monitor pull request activities via GitHub webhooks.
- Send tokens to contributors' wallets when their PRs are merged
- Announce the contributions and rewards on Twitter
This creates a transparent and automated way to incentivize and recognize open source contributions..
- 🔄 Automatic monitoring of PR merges via GitHub webhooks
- 💎 Automated token transfers on Solana blockchain
- 🐦 Automated Twitter announcements for rewards
- ✅ Secure webhook signature verification
- 💫 Support for custom token amounts
- 🔐 Secure key management
- 📊 Transaction tracking via Solana Explorer
- Node.js (v16 or higher)
- npm (v7 or higher)
- Solana CLI tools
- GitHub account with admin access to the repository
- Twitter Developer Account
- Access to Solana wallet/keypair
- Clone the repository:
git clone https://github.com/Emmanuel0705/rewarding-system
cd rewarding-system
npm install
- Configure environment variables:
cp example.env .env
Update the .env
file with your credentials:
# Solana Configuration
SOL_ENV=devnet
SECRET_KEY=your_solana_secret_key
TOKEN_CA=your_token_contract_address
TOKEN_NAME=your_token_name
TOKEN_SYMBOL=your_token_name
TOKEN_DECIMALS=9
TOKEN_URI=your_token_metadata_uri
# GitHub Configuration
GITHUB_SECRET=your_webhook_secret
# Twitter Configuration
TWITTER_APP_KEY=your_twitter_api_key
TWITTER_APP_SECRET=your_twitter_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_SECRET=your_access_token_secret
- Create a Solana keypair (if you don't have one):
npm run create-keypair
This will generate a new keypair and output the secret key. Update your .env
file with this key.
- Create a Solana token (optional):
npm run create-token
This will create a new token on the Solana blockchain. Update your .env
file with the token address.
- Set up Twitter API credentials:
- Create a Twitter Developer account at https://developer.twitter.com
- Create a new app and generate API keys
- Update your
.env
file with the Twitter credentials
npm run dev
npm start
- Go to your GitHub repository settings
- Navigate to Webhooks > Add webhook
- Set Payload URL to your server URL (e.g.,
https://your-domain.com/webhook
) - Set Content type to
application/json
- Set Secret to the same value as your
GITHUB_WEBHOOK_SECRET
- Select "Pull request" events only
- Enable SSL verification if using HTTPS
- This bot only processes pull requests that are merged to the master branch
- Contributors must include their Solana wallet address in their PR title or body using the format:
- The bot verifies webhook signatures for security
- All transactions are performed on the network specified in
SOL_ENV
- Failed transactions are logged but do not stop the webhook processing
-
When a PR is merged to master:
- Webhook receives the GitHub event
- Bot verifies the webhook signature
- Bot extracts the contributor's wallet address from PR description Example PR format: Title or Body: Fixed navigation bug <AF3sD9...y5K2P>
- Bot initiates token transfer to the contributor
- Bot creates a Twitter post announcing the contribution
-
The Twitter post includes:
- Contributor's GitHub username
- Repository name
- PR number
- Token amount
- Transaction link on Solana Explorer
- Webhook not working: Verify your webhook secret and server URL
- Token transfer failing: Check your Solana wallet balance and network status
- Twitter posts not appearing: Verify your Twitter API credentials
- Invalid signatures: Ensure your webhook secret matches in GitHub and
.env
Contributions are welcome! Please feel free to submit a Pull Request.
Please do not commit your .env
file or expose your private keys. The .env
file is included in .gitignore
for your protection.