Decentralized Recurring Payments on Solana
The backend processor is a TypeScript-based service that monitors active mandates and automatically executes payments when due. It includes:
- Mandate monitoring: Continuously scans for mandates approaching their next payment date
- Automatic execution: Executes payments on behalf of users at the scheduled intervals
- Transaction logging: Keeps detailed records of all payment transactions
- Rust installed
- Solana CLI configured for devnet
- Anchor framework (v0.30.1+)
- Node.js (v16+)
-
Clone the repository:
git clone https://github.com/DMANDATE/DMANDATE.git cd DMANDATE -
Install dependencies:
npm install cd cli && npm install && cd .. cd backend && npm install && cd ..
-
Build the program:
anchor build
-
Deploy to devnet (if needed):
anchor deploy --provider.cluster devnet
cd cli
npm run startcd backend
npm run startFor detailed information about the project workflow, see workflow.md.
For deployment details, see DEPLOYMENT.md.
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is licensed under the MIT License.
Organization: DMANDATE
Developer: DEEPANSHUormation
Organization: DMANDATE
Developer: DEEPANSHU
Network: Solana Devnet
Program ID: 8kHcaQxyxKFAK6t8KRKDUmn9FaHGZi8kwomBaSDVc4X1
Deployment Signature: 5L6VAUU4KzXy1KwnGgoJRPMSny75KgeyQsiRjRPL3mw9Jy2rEAYYARpnhtp4vGvVUTKZMGRJFNfkZMqCd1DRx5yh
DMANDATE is a Solana-based protocol for decentralized recurring payments. Users pre-approve a PDA to transfer tokens (e.g., USDC) without locking funds. A backend processes payments at scheduled intervals, ensuring self-custody and transparency. Ideal for subscriptions, salaries, and bills, DMANDATE offers a trustless, non-custodial alternative to traditional e-mandates.
- Non-custodial recurring payments: Users maintain control of their funds at all times
- Programmable payment schedules: Set custom frequencies for payment execution
- Transparent on-chain history: All payments and mandates are recorded on the Solana blockchain
- Automated payment processing: Backend service checks and executes due payments
- User-friendly CLI: Command-line interface for managing mandates and payments
- Web3 friendly: Built natively for Solana's SPL tokens
dmandate/
βββ backend/ # Backend payment processor service
β βββ idl/ # Anchor IDL for the dmandate program
β βββ src/ # Source code for the mandate processor
βββ cli/ # Command-line interface tool
βββ programs/ # Solana smart contracts written in Rust
β βββ dmandate/ # Main dmandate program
βββ tests/ # Integration tests for the program
The DMANDATE smart contract is built using the Anchor framework and includes the following key instructions:
register_user: Registers a user in the systemcreate_mandate: Creates a new recurring payment mandateexecute_payment: Executes a payment for an active mandatecancel_mandate: Cancels an active mandatereapprove_mandate: Updates the approval amount for an existing mandateclose_payment_history: Closes a payment history record to reclaim rent
The backend service monitors active mandates on the Solana blockchain and automatically executes payments when they are due.
- Periodic checking of all active mandates
- Automatic payment execution for due mandates
- Error handling for failed payments
- Configurable settings via environment variables or config file
- Logging of all operations
The mandate processor can be configured with the following options:
| Option | Environment Variable | Description | Default |
|---|---|---|---|
| Check Interval | CHECK_INTERVAL |
How often to check for payable mandates (ms) | 60000 (1 min) |
| RPC URL | RPC_URL |
Solana RPC URL | http://localhost:8899 |
| Keypair Path | KEYPAIR_PATH |
Path to keypair JSON file | ~/.config/solana/id.json |
| Program ID | PROGRAM_ID |
DMANDATE program ID | 8kHcaQxyxKFAK6t8KRKDUmn9FaHGZi8kwomBaSDVc4X1 |
| Batch Size | BATCH_SIZE |
Max mandates to process in one batch | 100 |
| Buffer Time | BUFFER_TIME |
Time buffer before scheduled payment (seconds) | 60 |
| Log Level | LOG_LEVEL |
Logging level (debug, info, warn, error) | info |
| Notifications | ENABLE_NOTIFICATIONS |
Enable payment notifications | false |
The DMANDATE CLI tool provides a convenient way to interact with the smart contract.
See the CLI README for detailed usage instructions.
- Node.js v14+ and npm
- Rust and Cargo
- Solana CLI tools
- Anchor Framework
-
Clone the repository:
git clone https://github.com/yourusername/dmandate.git cd dmandate -
Install dependencies:
npm install
-
Build the Solana program:
anchor build
-
Generate the program ID (if needed):
solana-keygen new -o target/deploy/dmandate-keypair.json anchor keys list
Update the program ID in
Anchor.tomlandlib.rs -
Setup the backend processor:
cd backend npm install -
Setup the CLI:
cd cli npm install npm link # Optional, to use CLI globally
-
Create a
.envfile in the backend directory:RPC_URL=https://api.devnet.solana.com KEYPAIR_PATH=/path/to/your/keypair.json CHECK_INTERVAL=60000 BUFFER_TIME=60 LOG_LEVEL=info
cd backend
npm run build
node dist/index.jsOr use a process manager like PM2:
npm install -g pm2
pm2 start dist/index.js --name mandate-processor-
Start a local Solana validator:
solana-test-validator
-
Deploy the program to the local network:
anchor deploy
-
Run the mandate processor against local network:
cd backend RPC_URL=http://localhost:8899 npm run start
- Modify code in
programs/dmandate/src/ - Build with
anchor build - Update IDL if needed:
anchor idl parse -f programs/dmandate/src/lib.rs -o target/idl/dmandate.json - Copy the new IDL to the backend:
cp target/idl/dmandate.json backend/idl/ - Deploy:
anchor deploy
Run the test suite:
anchor testcd backend
npm test-
Build the program:
anchor build
-
Deploy to your desired network:
anchor deploy --provider.cluster devnet # For devnet # OR anchor deploy --provider.cluster mainnet # For mainnet
-
Verify the program ID and update configuration as needed.
-
Build the backend:
cd backend npm run build -
Deploy using your preferred method (PM2, Docker, cloud services).
-
Make sure to set the appropriate environment variables for your deployment.