{"id":28304189,"url":"https://github.com/dorkydhruv/dmandate","last_synced_at":"2025-06-16T22:31:25.393Z","repository":{"id":279435236,"uuid":"938795694","full_name":"dorkydhruv/dmandate","owner":"dorkydhruv","description":"A recurring payments protocol on Solana built with Anchor.","archived":false,"fork":false,"pushed_at":"2025-03-02T21:05:54.000Z","size":326,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T00:12:20.039Z","etag":null,"topics":["anchor","solana","spl-token"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dorkydhruv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-25T14:14:13.000Z","updated_at":"2025-03-20T19:31:27.000Z","dependencies_parsed_at":"2025-02-25T15:33:04.752Z","dependency_job_id":"0c1ee234-256c-47bd-9dbd-6c83e89cba1e","html_url":"https://github.com/dorkydhruv/dmandate","commit_stats":null,"previous_names":["dorkydhruv/dmandate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dorkydhruv/dmandate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorkydhruv%2Fdmandate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorkydhruv%2Fdmandate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorkydhruv%2Fdmandate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorkydhruv%2Fdmandate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dorkydhruv","download_url":"https://codeload.github.com/dorkydhruv/dmandate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dorkydhruv%2Fdmandate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260251321,"owners_count":22981010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anchor","solana","spl-token"],"created_at":"2025-05-24T00:12:18.176Z","updated_at":"2025-06-16T22:31:25.382Z","avatar_url":"https://github.com/dorkydhruv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DMANDATE - Decentralized Recurring Payments on Solana\n\nDMANDATE 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.\n\nDEVNET ADDRESS - [BXXJENjyLn4ZGYfkDpSxZ6Vt7TcxW7BQJgWaGiQGbfed](https://explorer.solana.com/address/BXXJENjyLn4ZGYfkDpSxZ6Vt7TcxW7BQJgWaGiQGbfed?cluster=devnet)\n\n![Architecture-Diagram](architechture.png)\n\n### In action\n\n\u003cdiv\u003e\n    \u003ca href=\"https://www.loom.com/share/7970a0ed0e654e12ab1ed7188e05fb31\"\u003e\n      \u003cp\u003eDMANDATE CAPSTONE - Watch Video\u003c/p\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.loom.com/share/7970a0ed0e654e12ab1ed7188e05fb31\"\u003e\n      \u003cimg style=\"max-width:300px;\" src=\"https://cdn.loom.com/sessions/thumbnails/7970a0ed0e654e12ab1ed7188e05fb31-0361c52cac1411e2-full-play.gif\"\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n## Table of Contents\n\n- [Features](#features)\n- [Repository Structure](#repository-structure)\n- [Smart Contract](#smart-contract)\n- [Backend Mandate Processor](#backend-mandate-processor)\n- [CLI Tool](#cli-tool)\n- [Installation \u0026 Setup](#installation--setup)\n- [Development](#development)\n- [Testing](#testing)\n- [Deployment](#deployment)\n\n## Features\n\n- **Non-custodial recurring payments**: Users maintain control of their funds at all times\n- **Programmable payment schedules**: Set custom frequencies for payment execution\n- **Transparent on-chain history**: All payments and mandates are recorded on the Solana blockchain\n- **Automated payment processing**: Backend service checks and executes due payments\n- **User-friendly CLI**: Command-line interface for managing mandates and payments\n- **Web3 friendly**: Built natively for Solana's SPL tokens\n\n## Repository Structure\n\n```\ndmandate/\n├── backend/             # Backend payment processor service\n│   ├── idl/             # Anchor IDL for the dmandate program\n│   └── src/             # Source code for the mandate processor\n├── cli/                 # Command-line interface tool\n├── programs/            # Solana smart contracts written in Rust\n│   └── dmandate/        # Main dmandate program\n└── tests/               # Integration tests for the program\n```\n\n## Smart Contract\n\nThe DMANDATE smart contract is built using the Anchor framework and includes the following key instructions:\n\n- `register_user`: Registers a user in the system\n- `create_mandate`: Creates a new recurring payment mandate\n- `execute_payment`: Executes a payment for an active mandate\n- `cancel_mandate`: Cancels an active mandate\n- `reapprove_mandate`: Updates the approval amount for an existing mandate\n- `close_payment_history`: Closes a payment history record to reclaim rent\n\n## Backend Mandate Processor\n\nThe backend service monitors active mandates on the Solana blockchain and automatically executes payments when they are due.\n\n### Features\n\n- Periodic checking of all active mandates\n- Automatic payment execution for due mandates\n- Error handling for failed payments\n- Configurable settings via environment variables or config file\n- Logging of all operations\n\n### Configuration\n\nThe mandate processor can be configured with the following options:\n\n| Option         | Environment Variable   | Description                                    | Default                                      |\n| -------------- | ---------------------- | ---------------------------------------------- | -------------------------------------------- |\n| Check Interval | `CHECK_INTERVAL`       | How often to check for payable mandates (ms)   | 60000 (1 min)                                |\n| RPC URL        | `RPC_URL`              | Solana RPC URL                                 | http://localhost:8899                        |\n| Keypair Path   | `KEYPAIR_PATH`         | Path to keypair JSON file                      | ~/.config/solana/id.json                     |\n| Program ID     | `PROGRAM_ID`           | DMANDATE program ID                            | BXXJENjyLn4ZGYfkDpSxZ6Vt7TcxW7BQJgWaGiQGbfed |\n| Batch Size     | `BATCH_SIZE`           | Max mandates to process in one batch           | 100                                          |\n| Buffer Time    | `BUFFER_TIME`          | Time buffer before scheduled payment (seconds) | 60                                           |\n| Log Level      | `LOG_LEVEL`            | Logging level (debug, info, warn, error)       | info                                         |\n| Notifications  | `ENABLE_NOTIFICATIONS` | Enable payment notifications                   | false                                        |\n\n## CLI Tool\n\nThe DMANDATE CLI tool provides a convenient way to interact with the smart contract.\n\nSee the [CLI README](cli/README.md) for detailed usage instructions.\n\n## Installation \u0026 Setup\n\n### Prerequisites\n\n- Node.js v14+ and npm\n- Rust and Cargo\n- Solana CLI tools\n- Anchor Framework\n\n### Setting Up the Project\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/yourusername/dmandate.git\n   cd dmandate\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Build the Solana program:\n\n   ```bash\n   anchor build\n   ```\n\n4. Generate the program ID (if needed):\n\n   ```bash\n   solana-keygen new -o target/deploy/dmandate-keypair.json\n   anchor keys list\n   ```\n\n   Update the program ID in `Anchor.toml` and `lib.rs`\n\n5. Setup the backend processor:\n\n   ```bash\n   cd backend\n   npm install\n   ```\n\n6. Setup the CLI:\n\n   ```bash\n   cd cli\n   npm install\n   npm link  # Optional, to use CLI globally\n   ```\n\n7. Create a `.env` file in the backend directory:\n   ```\n   RPC_URL=https://api.devnet.solana.com\n   KEYPAIR_PATH=/path/to/your/keypair.json\n   CHECK_INTERVAL=60000\n   BUFFER_TIME=60\n   LOG_LEVEL=info\n   ```\n\n### Running the Mandate Processor\n\n```bash\ncd backend\nnpm run build\nnode dist/index.js\n```\n\nOr use a process manager like PM2:\n\n```bash\nnpm install -g pm2\npm2 start dist/index.js --name mandate-processor\n```\n\n## Development\n\n### Local Development Environment\n\n1. Start a local Solana validator:\n\n   ```bash\n   solana-test-validator\n   ```\n\n2. Deploy the program to the local network:\n\n   ```bash\n   anchor deploy\n   ```\n\n3. Run the mandate processor against local network:\n   ```bash\n   cd backend\n   RPC_URL=http://localhost:8899 npm run start\n   ```\n\n### Making Changes to the Smart Contract\n\n1. Modify code in `programs/dmandate/src/`\n2. Build with `anchor build`\n3. Update IDL if needed: `anchor idl parse -f programs/dmandate/src/lib.rs -o target/idl/dmandate.json`\n4. Copy the new IDL to the backend: `cp target/idl/dmandate.json backend/idl/`\n5. Deploy: `anchor deploy`\n\n## Testing\n\n### Smart Contract Tests\n\nRun the test suite:\n\n```bash\nanchor test\n```\n\n### Backend Tests\n\n```bash\ncd backend\nnpm test\n```\n\n## Deployment\n\n### Program Deployment\n\n1. Build the program:\n\n   ```bash\n   anchor build\n   ```\n\n2. Deploy to your desired network:\n\n   ```bash\n   anchor deploy --provider.cluster devnet  # For devnet\n   # OR\n   anchor deploy --provider.cluster mainnet  # For mainnet\n   ```\n\n3. Verify the program ID and update configuration as needed.\n\n### Backend Deployment\n\n1. Build the backend:\n\n   ```bash\n   cd backend\n   npm run build\n   ```\n\n2. Deploy using your preferred method (PM2, Docker, cloud services).\n\n3. Make sure to set the appropriate environment variables for your deployment.\n\n## License\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdorkydhruv%2Fdmandate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdorkydhruv%2Fdmandate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdorkydhruv%2Fdmandate/lists"}