Sol.College

Full lesson

openbudget-id

Real-time government spending transparency on Solana | Civic tech for democratic accountability | Indonesia open governance

What it does

From the project README:

OpenBudget.ID is a blockchain-based transparency platform that enables Indonesian ministries to record government spending milestones on-chain, allowing citizens to verify in real-time how public funds are allocated and used.
Original
RECTOR-LABS/openbudget-id
SuperStack fork
Blockchains/openbudget-id @ cf76dde
Stars
1
Last push (original)
2026-07-14
Languages
TypeScript, PLpgSQL, Rust, Shell, Ruby, Dockerfile
Detected stack
AnchorNext.jsweb3.js
Categories
Governance & DAOs
Licence
MIT
Homepage
https://openbudget-livid.vercel.app

Architecture

85 source files. By extension: .tsx ×40, .ts ×37, .rs ×7, .js ×1.

Top-level directorySource files
frontend76
solana-program9

On-chain programs: solana-program/openbudget/programs/openbudget

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/openbudget-id/. 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.

RECTOR-LABS/openbudget-id · solana-program/openbudget/programs/openbudget/src/instructions/initialize_platform.rs L1–24 @ cf76dde · MIT · original
use anchor_lang::prelude::*;use crate::state::PlatformState; #[derive(Accounts)]pub struct InitializePlatform<'info> {    #[account(        init,        payer = admin,        space = PlatformState::LEN,        seeds = [b"platform"],        bump    )]    pub platform_state: Account<'info, PlatformState>,     #[account(mut)]    pub admin: Signer<'info>,     pub system_program: Program<'info, System>,} pub fn handler(ctx: Context<InitializePlatform>) -> Result<()> {    let platform_state = &mut ctx.accounts.platform_state;    platform_state.admin = ctx.accounts.admin.key();    platform_state.project_count = 0;
  1. Line 7 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 10 seeds = [b"platform"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 11 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 16 pub admin: Signer<'info>,: Requires this account to have signed the transaction.
RECTOR-LABS/openbudget-id · solana-program/openbudget/programs/openbudget/src/instructions/initialize_project.rs L37–59 @ cf76dde · MIT · original
    // Input validation    require!(project_id.len() <= 32, ErrorCode::ProjectIdTooLong);    require!(title.len() > 0 && title.len() <= 100, ErrorCode::InvalidTitle);    require!(total_budget > 0, ErrorCode::InvalidBudget);     let project = &mut ctx.accounts.project;    project.id = project_id;    project.title = title;    project.ministry = ministry;    project.total_budget = total_budget;    project.total_allocated = 0;    project.total_released = 0;    project.milestone_count = 0;    project.created_at = Clock::get()?.unix_timestamp;    project.authority = ctx.accounts.authority.key();     // Increment platform project counter    let platform_state = &mut ctx.accounts.platform_state;    platform_state.project_count = platform_state.project_count.checked_add(1).unwrap();     msg!("Project created: {} by {}", project.id, project.authority);    Ok(())}
  1. Line 38 require!(project_id.len() <= 32, ErrorCode::ProjectIdTooLong);: An explicit validation that aborts the instruction with an error.
  2. Line 50 project.created_at = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  3. Line 55 platform_state.project_count = platform_state.project_count.checked_add(1).unwrap();: Uses checked arithmetic so overflow fails instead of wrapping.
  4. Line 57 msg!("Project created: {} by {}", project.id, project.authority);: Logs to the program log, which is visible in explorers and the test output.
RECTOR-LABS/openbudget-id · solana-program/openbudget/programs/openbudget/src/instructions/add_milestone.rs L1–23 @ cf76dde · MIT · original
use anchor_lang::prelude::*;use crate::state::{Project, Milestone};use crate::ErrorCode; #[derive(Accounts)]#[instruction(project_id: String, index: u8)]pub struct AddMilestone<'info> {    #[account(        init,        payer = authority,        space = Milestone::LEN,        seeds = [b"milestone", project_id.as_bytes(), &[index]],        bump    )]    pub milestone: Account<'info, Milestone>,     #[account(        mut,        seeds = [b"project", project_id.as_bytes()],        bump,        constraint = project.authority == authority.key() @ ErrorCode::UnauthorizedAccess    )]    pub project: Account<'info, Project>,
  1. Line 9 init,: Creates and pays for a new account. Space and payer must be specified.
  2. Line 12 seeds = [b"milestone", project_id.as_bytes(), &[index]],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 13 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
RECTOR-LABS/openbudget-id · solana-program/openbudget/programs/openbudget/src/instructions/release_funds.rs L1–24 @ cf76dde · MIT · original
use anchor_lang::prelude::*;use crate::state::{Project, Milestone};use crate::ErrorCode; #[derive(Accounts)]#[instruction(project_id: String, index: u8)]pub struct ReleaseFunds<'info> {    #[account(        mut,        seeds = [b"milestone", project_id.as_bytes(), &[index]],        bump,        constraint = !milestone.is_released @ ErrorCode::MilestoneAlreadyReleased    )]    pub milestone: Account<'info, Milestone>,     #[account(        mut,        seeds = [b"project", project_id.as_bytes()],        bump,        constraint = project.authority == authority.key() @ ErrorCode::UnauthorizedAccess    )]    pub project: Account<'info, Project>,     pub authority: Signer<'info>,
  1. Line 10 seeds = [b"milestone", project_id.as_bytes(), &[index]],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  2. Line 11 bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  3. Line 24 pub authority: Signer<'info>,: Requires this account to have signed the transaction.

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
solana-program/openbudgetnpm run lintprettier */*.js "*/**/*{.js,.ts}" --check
frontendnpm run devnext dev
frontendnpm run startnext start
frontendnpm run buildnext build
frontendnpm run lintnext lint
solana-program/openbudgetanchor buildcompile programs and generate IDLs
solana-program/openbudgetanchor testlocal validator + test suite
solana-program/openbudgetanchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 \

What you could build from it