Sol.College

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 directorySource files
app111
(root)3
anchor2
scripts1

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.

NikhilRaikwar/AllocRail · 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;
  1. Line 14 require!(ctx.accounts.vault.lamports() == 0, VaultError::VaultAlreadyExists);: An explicit validation that aborts the instruction with an error.
  2. Line 20 CpiContext::new(: Makes a cross-program invocation into another program.
  3. Line 36 let bump = ctx.bumps.vault;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
NikhilRaikwar/AllocRail · 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);
  1. Line 137 createTransferCheckedInstruction(: A checked token transfer, which also verifies the mint and decimals.
  2. 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.

DirectoryCommandRuns
.npm run devnext dev
.npm run startnext start
.npm run buildnext build
.npm run linteslint
anchoranchor buildcompile programs and generate IDLs
anchoranchor testlocal validator + test suite
anchoranchor run testcargo test

What you could build from it

Used in lessons