Full lesson
AllocRail
AllocRail is a programmable treasury router for SaaS and AI founders using Dodo Payments.
What it does
From the project README:
AllocRail turns verified Dodo payment and billing events into founder-controlled Solana USDC payout intents for contractor escrow, tax reserves, founder shares, and AI-agent budgets, with receipt-backed proof after settlement.
- Original
- NikhilRaikwar/AllocRail
- SuperStack fork
- Blockchains/AllocRail @
9d2b6e8 - Stars
- 2
- Last push (original)
- 2026-05-12
- Languages
- TypeScript, CSS, PLpgSQL, Rust, Python, JavaScript
- Detected stack
- @solana/kitAnchorNext.jsweb3.js
- Categories
- AI & AgentsDeFi
- Licence
- MIT
- Homepage
- https://www.allocrail.dev/
Architecture
117 source files. By extension: .ts ×67, .tsx ×46, .rs ×2, .js ×1, .py ×1.
| Top-level directory | Source files |
|---|---|
app | 111 |
(root) | 3 |
anchor | 2 |
scripts | 1 |
On-chain programs: anchor/programs/vault
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/allocrail/. 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.
anchor/programs/vault/src/lib.rs L13–36 @ 9d2b6e8 · MIT · original pub fn deposit(ctx: Context<VaultAction>, amount: u64) -> Result<()> { require!(ctx.accounts.vault.lamports() == 0, VaultError::VaultAlreadyExists); let rent = Rent::get()?.minimum_balance(0); require!(amount > rent, VaultError::InvalidAmount); transfer( CpiContext::new( ctx.accounts.system_program.to_account_info(), Transfer { from: ctx.accounts.signer.to_account_info(), to: ctx.accounts.vault.to_account_info(), }, ), amount, )?; Ok(()) } pub fn withdraw(ctx: Context<VaultAction>) -> Result<()> { require!(ctx.accounts.vault.lamports() > 0, VaultError::InvalidAmount); let bump = ctx.bumps.vault;- Line 14
require!(ctx.accounts.vault.lamports() == 0, VaultError::VaultAlreadyExists);: An explicit validation that aborts the instruction with an error. - Line 20
CpiContext::new(: Makes a cross-program invocation into another program. - Line 36
let bump = ctx.bumps.vault;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
app/components/payout-intent-actions.tsx L133–155 @ 9d2b6e8 · MIT · original ); } transaction.add( createTransferCheckedInstruction( senderAta, mint, recipientAta, authority, BigInt(plan.amountBaseUnits), plan.decimals ) ); const wireBytes = transaction.serialize({ requireAllSignatures: false, verifySignatures: false, }); const signatureBytes = await wallet.sendTransaction( wireBytes, `solana:${cluster}` ); const signature = bs58.encode(signatureBytes);- Line 137
createTransferCheckedInstruction(: A checked token transfer, which also verifies the mint and decimals. - Line 151
const signatureBytes = await wallet.sendTransaction(: Submits the signed transaction to the cluster.
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 | next dev |
. | npm run start | next start |
. | npm run build | next build |
. | npm run lint | eslint |
anchor | anchor build | compile programs and generate IDLs |
anchor | anchor test | local validator + test suite |
anchor | anchor run test | cargo test |
What you could build from it
- Fork the SuperStack copy and extend it within the AI & Agents gaps listed on the idea page.
- Learn the pattern first: AI agents on Solana
- Learn the pattern first: Building and sending transactions from a client