Open-source template for processing payroll payments in USDC on Solana blockchain
- β Batch USDC Payments - Process multiple payments from a CSV file
- β Dry Run Mode - Test payments without sending real transactions
- β Error Handling - Automatic retries and detailed error reporting
- β Transaction Logging - Save all payment results to JSON
- β Balance Checking - Verify sufficient funds before processing
- β Customizable - Easy configuration via environment variables
- β Production Ready - Built with TypeScript and best practices
- Node.js v16 or higher
- npm or yarn
- Solana wallet with some SOL for transaction fees
- USDC tokens in your wallet (for production payments)
git clone https://github.com/yourusername/solana-usdc-payroll-template.git
cd solana-usdc-payroll-templatenpm installcp .env.example .envEdit .env with your configuration:
SOLANA_NETWORK=devnet
SOLANA_RPC_URL=https://api.devnet.solana.com
PAYER_PRIVATE_KEY=your_base58_private_key_here
USDC_MINT_ADDRESS=4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU
DRY_RUN=true
CSV_FILE_PATH=./examples/employees.csvCreate or edit examples/employees.csv:
employee_name,wallet_address,amount,description
Alice Johnson,5ZWj7a1f8tWkjBESHKgrLmXshuXxqeY9SYcfbshpAqPG,1500.00,December Salary
Bob Smith,7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU,2000.00,December Salarynpm startThis will simulate payments without sending them.
When ready, set DRY_RUN=false in .env, then:
npm startsolana-usdc-payroll-template/
βββ src/
β βββ config.ts # Configuration management
β βββ payroll.ts # Core payment logic
β βββ utils.ts # Helper functions
β βββ index.ts # Main entry point
βββ examples/
β βββ employees.csv # Sample employee list
β βββ .env.example # Example environment variables
βββ .gitignore
βββ package.json
βββ tsconfig.json
βββ README.md
| Variable | Description | Default | Required |
|---|---|---|---|
SOLANA_NETWORK |
Network to use (devnet/mainnet-beta) | devnet | No |
SOLANA_RPC_URL |
RPC endpoint URL | - | Yes |
PAYER_PRIVATE_KEY |
Your wallet's private key (base58) | - | Yes |
USDC_MINT_ADDRESS |
USDC token mint address | - | Yes |
DRY_RUN |
Simulate without sending (true/false) | true | No |
CSV_FILE_PATH |
Path to CSV file | ./examples/employees.csv | No |
MAX_RETRIES |
Transaction retry attempts | 3 | No |
BATCH_DELAY |
Delay between payments (ms) | 1000 | No |
- Devnet:
4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU - Mainnet:
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
Your CSV file must have these columns:
| Column | Description | Example |
|---|---|---|
employee_name |
Employee's name | Alice Johnson |
wallet_address |
Solana wallet address | 5ZWj7a1f8t... |
amount |
Amount in USDC | 1500.00 |
description |
Payment description | December Salary |
- Never commit
.envfile - It contains your private key - Use environment-specific keys - Different keys for dev/prod
- Test on devnet first - Always test before mainnet
- Keep private keys secure - Store in password manager
- Monitor transaction results - Check all signatures on Solscan
- Limit wallet balance - Don't keep more USDC than needed
- Change
SOLANA_NETWORK=mainnet-beta - Update
SOLANA_RPC_URLto mainnet RPC - Use mainnet USDC mint address
- Fund your wallet with SOL and USDC
- Set
DRY_RUN=false
# Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/v1.17.0/install)"
# Get devnet SOL
solana airdrop 2
# Use a faucet for devnet USDC (search "Solana devnet USDC faucet")# Using Solana CLI
solana-keygen new --no-bip39-passphrase --outfile keypair.json
# Get the private key in base58
solana-keygen pubkey keypair.json| Command | Description |
|---|---|
npm start |
Run payroll processor |
npm run build |
Compile TypeScript to JavaScript |
npm run dry-run |
Force dry run mode |
- Check your USDC balance matches the total payment amount
- Ensure you have SOL for transaction fees (~0.005 SOL per transaction)
- Verify wallet addresses in CSV are valid Solana addresses
- Check for extra spaces or special characters
- Check your internet connection
- Verify RPC endpoint is responding
- Try reducing
BATCH_DELAYor increasingMAX_RETRIES
- Run
npm installagain - Delete
node_modulesandpackage-lock.json, then reinstall
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This software is provided "as is" without warranty of any kind. Use at your own risk. Always test thoroughly on devnet before using with real funds on mainnet.
- Built with Solana Web3.js
- Uses SPL Token standard
- Inspired by the need for simple, open-source crypto payroll solutions
- Create an Issue
- Star β this repo if you find it helpful!
Made with β€οΈ for the Solana community