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 directory | Source files |
|---|---|
src | 83 |
backend | 14 |
(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.
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(),- Line 88
let transfer_to_processor_ctx = CpiContext::new(: Makes a cross-program invocation into another program. - Line 97
token::transfer(transfer_to_processor_ctx, amount)?;: An SPL token transfer through the Token Program. - Line 100
let seeds = &[: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 102
&[payment_processor.bump],: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - 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.
backend/src/services/solana.service.ts L1–24 @ 72a3609 · MIT · originalimport { 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'; /**- Line 8
sendAndConfirmTransaction,: Submits the signed transaction to the cluster. - 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.
| Directory | Command | Runs |
|---|---|---|
. | npm run dev | vite |
. | npm run build | vite build |
. | npm run lint | eslint . |
backend | npm run dev | nodemon --exec ts-node src/index.ts |
backend | npm run start | node dist/index.js |
backend | npm run build | tsc |
backend | npm run test | jest |
backend | npm run lint | eslint src/**/*.ts |
backend/anchor | npm run build | anchor build |
backend/anchor | npm run test | anchor test |
backend/anchor | npm run deploy | anchor deploy |
backend/anchor | anchor build | compile programs and generate IDLs |
backend/anchor | anchor test | local validator + test suite |
backend/anchor | anchor run test | yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts |
What you could build from it
- Fork the SuperStack copy and extend it within the DeFi gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)
- Learn the pattern first: SPL Tokens: mints, accounts and transfers