SoDapV2.0 is a decentralized in-store shopping platform on Solana with built-in Buy Now, Pay Later (BNPL), a transparent loyalty system, and verifiable refunds. Payments run through on-chain escrow for security and instant settlement, while BNPL and loyalty logic are enforced on-chain for consistency and fairness.
- BNPL: On-chain 20% downpayment with escrow; remaining balance is scheduled off-chain. Refunds return the downpayment and paid loans.
- Loyalty: Earn 10 points per 1 SOL actually paid; redeem at 100 points = 1 SOL. Points are awarded and deducted based on real spend and refund amounts.
- Refunds: Fast, transparent, and programmaticβescrow-backed and verified on-chain, aligned with BNPL and loyalty rules for predictable outcomes.
- Overview
- What's New in v2.0
- Key Features
- BNPL - Buy Now, Pay Later
- Loyalty Points Program
- Pay with Points
- Blockchain Features
- Tested Functionalities (18 Passing Tests)
- Getting Started
- Architecture
- Development
- Contributing
- License
- BNPL correctness & refunds: BNPL refunds now return only the downpayment, not the full amount. Loyalty points deductions align with the amount actually paid.
- Pay with Points (Direct & BNPL): Redeem loyalty points during checkout. Rate: 100 points = 1 SOL. For BNPL, the discount is applied to the total before calculating the 20% downpayment.
- Loyalty points integration: Earn 10 points per SOL you actually pay. Refunds deduct points accordingly. UI shows refund deductions with a red minus (e.g., -10).
- Robust UX: Payment dialog is responsive with fixed header/footer and scrollable content for smaller screens.
- Instant Settlement: Payments settle in seconds vs. days in traditional systems
- Escrow Protection: Smart contract escrow eliminates third parties and reduces fees
- Transparent Refunds: On-chain verification provides faster dispute resolution
- Admin Management: Add and remove admins with proper authorization checks
- User Wallet Creation: Create and verify user wallets directly on the blockchain
- Role Verification: Validate transaction authority based on wallet signatures
- Store Registration: Create stores with secure PDA-based identification
- Metadata Updates: Update store information with proper ownership verification
- Owner-Based Control: Store operations restricted to verified store owners
- Product Registration: Add products to stores with secure on-chain storage
- Product Updates: Modify product details with ownership verification
- Product Deactivation: Safely remove products from availability
- Purchase Cart: Process purchases with escrow-based payment protection
- Fund Release: Securely transfer funds from escrow to store owners
- Refund Handling: Process refunds with proper authorization checks
- Minimum downpayment: 20% of the total after any points discount (on-chain enforced).
- Escrow: Only the downpayment is held in escrow for BNPL.
- Refunds: BNPL refunds return only the downpayment. Loyalty points are deducted based on what was actually paid (10 pts/SOL).
- Grounded in code:
- On-chain:
sodap-mono/programs/sodap/src/instructions/bnpl.rs(min_downpayment_percent = 2000),sodap-mono/programs/sodap/src/lib.rs(20% calculation). - Frontend refund flow:
sodap-mono/app/src/hooks/useRefundTransaction.ts,sodap-mono/app/src/components/dashboard/manager/RefundsTab.tsx. - Tests:
sodap-mono/tests/bnpl_loyalty_integration.ts.
- On-chain:
- Choose BNPL in
PaymentMethodDialog. - Optionally redeem points (discount applies before downpayment calculation).
- Pay the 20% downpayment; remaining balance is scheduled off-chain/UI.
- If refunded, only the downpayment returns; points are deducted proportionally.
- Earn 10 points per 1 SOL actually paid.
- Direct payments: points are based on the net amount after any points redemption.
- BNPL: points are based on the downpayment amount.
- Code:
sodap-mono/app/src/hooks/usePayment.ts,sodap-mono/app/src/hooks/useBnplPayment.ts,sodap-mono/programs/sodap/src/instructions/loyalty.rs.
- Redemption rate: 100 points = 1 SOL.
- Limits: You canβt redeem more than your available points or the order total.
- BNPL: Discount is applied to the order total first; then the 20% downpayment is computed on the discounted total.
- Code:
sodap-mono/app/src/components/payment/PaymentMethodDialog.tsx(pointsToSolRate = 100,downpaymentPercentage = 0.2).
- Refunds trigger point deductions at 10 pts/SOL of the refunded amount.
- BNPL refunds deduct based on the downpayment only.
- UI: Refund deductions are shown in red with a single minus (e.g.,
-10). - Code:
sodap-mono/app/src/hooks/useRefundTransaction.ts,sodap-mono/app/src/components/profile/RewardsTab.tsx.
- Available for both Direct and BNPL payments in the checkout dialog.
- Real-time calculations, validation, and a βMaxβ button for quick redemption.
- Dynamic pay button reflects the final amount after redemption (and BNPL downpayment when selected).
- Code:
sodap-mono/app/src/components/payment/PaymentMethodDialog.tsx.
- Program Derived Addresses (PDAs): Each store has a unique PDA that acts as a secure on-chain identifier.
- Store-Specific Lamport Vaults: Funds are managed in deterministic lamport vaults tied to each store's PDA.
- On-Chain Product Management: Immutable product details and pricing are stored securely.
- Escrow Payment System: PDAs handle escrow payments, ensuring buyer and seller protection.
- Immutable product and store data for transparency.
- Cryptographically secure transactions to ensure trust and reliability.
- Add Admin: Authorized addition of new admin accounts
- Remove Admin: Secure removal of admin privileges
- Admin Authorization: Proper verification of admin privileges
- Unauthorized Admin Operations: Correct rejection of unauthorized admin operations
- Create User Wallet: Successful creation of new user wallets
- Wallet Verification: Proper verification of wallet ownership
- Wallet Funding: Automatic funding of test accounts with sufficient SOL
- Register Store: Creation of new stores with proper ownership
- Update Store Metadata: Secure updating of store information
- Store Owner Verification: Verification of store ownership for operations
- Register Product: Addition of new products to stores
- Update Product: Modification of existing product details
- Deactivate Product: Proper deactivation of products
- Unauthorized Product Updates: Rejection of unauthorized product modifications
- Purchase Products: Successful purchase of products with proper escrow
- Release Funds: Secure release of funds from escrow to store owner
- Process Refunds: Proper handling of refund requests
- Insufficient Funds Handling: Graceful handling of insufficient funds errors
- Node.js 18+ and npm/yarn
- Solana CLI tools (
solana-cli) - Anchor Framework 0.28.0 or higher
- Solana wallet with devnet SOL (at least 1.0 SOL per test account)
git clone https://github.com/tenrikut/sodap-mono.git
cd sodap-mono
yarn install- All tests are run on Solana devnet for realistic testing conditions
- Use
anchor test --provider.cluster devnetto run tests on devnet - Ensure your wallet has sufficient SOL (1.0 SOL per test account recommended)
The following diagram illustrates the purchase flow in SoDap, showing how customers interact with stores and the Solana blockchain:
The BNPL flow shows the downpayment step, optional points redemption, and refund handling:
The following diagram illustrates the refund process in SoDap, showing how store managers process refund requests:
- Program Architecture: Rust-based Anchor program with modular instruction handlers
- Account Structure: Uses PDAs (Program Derived Addresses) for deterministic account generation
- State Management: Stores data in structured accounts with proper ownership validation
- Security Model: Implements rigorous access control and transaction verification
programs/
βββ sodap/
β βββ src/
β β βββ lib.rs # Main program entry point
β β βββ admin.rs # Admin management functionality
β β βββ user.rs # User wallet creation and verification
β β βββ store.rs # Store management operations
β β βββ product.rs # Product management operations
β β βββ payment.rs # Payment processing and escrow
β β βββ errors.rs # Custom error definitions
β β βββ state.rs # Account state definitions
β βββ Cargo.toml # Rust dependencies
βββ tests/ # Integration tests
βββ admin.ts # Admin management tests
βββ create_wallet.ts # User wallet tests
βββ store.ts # Store management tests
βββ product.ts # Product management tests
βββ payment.ts # Payment processing tests
- UI Framework: React with Vite for fast development and optimized builds
- Wallet Integration: Supports Phantom and other Solana wallets via wallet-adapter
- State Management: Context-based state management for user sessions and cart
- Styling: Modern UI with responsive design for all device types
src/
βββ components/ # Reusable UI components
β βββ common/ # Shared components (buttons, inputs, etc.)
β βββ layout/ # Layout components (header, footer, etc.)
β βββ store/ # Store-related components
β βββ product/ # Product-related components
βββ pages/ # Application pages
β βββ Home.tsx # Homepage
β βββ Store.tsx # Store details page
β βββ Product.tsx # Product details page
β βββ Cart.tsx # Shopping cart
β βββ Admin.tsx # Admin dashboard
βββ hooks/ # Custom React hooks
β βββ useWallet.ts # Wallet connection hook
β βββ useProgram.ts # Solana program interaction hook
βββ context/ # React context providers
β βββ WalletContext.tsx # Wallet connection context
β βββ CartContext.tsx # Shopping cart context
βββ utils/ # Utility functions
β βββ program-interface.ts # Anchor program interface
β βββ constants.ts # Application constants
βββ App.tsx # Main application component
anchor buildto build the programanchor deploy --provider.cluster devnetto deploy to devnetanchor test --provider.cluster devnetto run all tests on devnetscripts/transfer-sol.jsto transfer SOL between wallets for testing
- Fork the repository
- Create feature branches (
git checkout -b feature/amazing-feature) - Ensure all tests pass with
anchor test --provider.cluster devnet - Commit your changes (
git commit -m 'Add some 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.




