Sol.College

Full lesson

StablePay

Enterprise-grade stablecoin payment processor built on Solana that leverages Perena's stablecoin infrastructure.

What it does

From the project README:

[](https://reactjs.org/) [](https://www.typescriptlang.org/) [](https://vitejs.dev/) [](https://solana.com/) [](https://tailwindcss.com/) [](https://expressjs.com/) [](https://www.anchor-lang.com/) [](LICENSE)
Original
FarseenSh/StablePay
SuperStack fork
Blockchains/StablePay @ 72a3609
Stars
9
Last push (original)
2025-05-27
Languages
TypeScript, Rust, CSS, HTML, Shell, JavaScript
Detected stack
Anchorweb3.js
Categories
DeFiPayments
Licence
MIT

Architecture

101 source files. By extension: .tsx ×76, .ts ×22, .js ×2, .rs ×1.

Top-level directorySource files
src83
backend14
(root)4

On-chain programs: backend/anchor/programs/perenapay

Dapp: devnet deploy pending

⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/stablepay/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

FarseenSh/StablePay · backend/anchor/programs/perenapay/src/lib.rs L85–108 @ 72a3609 · MIT · original
        });         // Transfer full amount from customer to payment processor        let transfer_to_processor_ctx = CpiContext::new(            ctx.accounts.token_program.to_account_info(),            Transfer {                from: ctx.accounts.customer_token_account.to_account_info(),                to: ctx.accounts.payment_processor_token_account.to_account_info(),                authority: ctx.accounts.customer.to_account_info(),            },        );                token::transfer(transfer_to_processor_ctx, amount)?;         // Transfer fee to fee recipient        let seeds = &[            b"payment_processor".as_ref(),            &[payment_processor.bump],        ];        let signer = &[&seeds[..]];        let fee_transfer_ctx = CpiContext::new_with_signer(            ctx.accounts.token_program.to_account_info(),            Transfer {                from: ctx.accounts.payment_processor_token_account.to_account_info(),
  1. Line 88 let transfer_to_processor_ctx = CpiContext::new(: Makes a cross-program invocation into another program.
  2. Line 97 token::transfer(transfer_to_processor_ctx, amount)?;: An SPL token transfer through the Token Program.
  3. Line 100 let seeds = &[: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  4. Line 102 &[payment_processor.bump],: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  5. Line 105 let fee_transfer_ctx = CpiContext::new_with_signer(: Makes a CPI signed by a PDA. The signer seeds prove the program controls that address.
FarseenSh/StablePay · backend/src/services/solana.service.ts L1–24 @ 72a3609 · MIT · original
import {   Connection,   Keypair,   PublicKey,   Transaction,  SystemProgram,   TransactionInstruction,  sendAndConfirmTransaction,  TransactionSignature} from '@solana/web3.js';import {   TOKEN_PROGRAM_ID,   createTransferInstruction,  getAssociatedTokenAddress,  createAssociatedTokenAccountInstruction} from '@solana/spl-token';import * as anchor from '@project-serum/anchor';import * as fs from 'fs';import * as path from 'path';import { Buffer } from 'buffer';import config from '../config';import logger from '../utils/logger'; /**
  1. Line 8 sendAndConfirmTransaction,: Submits the signed transaction to the cluster.
  2. Line 13 createTransferInstruction,: An SPL token transfer through the Token Program.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
.npm run devvite
.npm run buildvite build
.npm run linteslint .
backendnpm run devnodemon --exec ts-node src/index.ts
backendnpm run startnode dist/index.js
backendnpm run buildtsc
backendnpm run testjest
backendnpm run linteslint src/**/*.ts
backend/anchornpm run buildanchor build
backend/anchornpm run testanchor test
backend/anchornpm run deployanchor deploy
backend/anchoranchor buildcompile programs and generate IDLs
backend/anchoranchor testlocal validator + test suite
backend/anchoranchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts

What you could build from it

Used in lessons