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 directory | Source files |
|---|---|
frontend | 76 |
solana-program | 9 |
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.
solana-program/openbudget/programs/openbudget/src/instructions/initialize_platform.rs L1–24 @ cf76dde · MIT · originaluse 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;- Line 7
init,: Creates and pays for a new account. Space and payer must be specified. - Line 10
seeds = [b"platform"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 11
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 16
pub admin: Signer<'info>,: Requires this account to have signed the transaction.
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(())}- Line 38
require!(project_id.len() <= 32, ErrorCode::ProjectIdTooLong);: An explicit validation that aborts the instruction with an error. - Line 50
project.created_at = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 55
platform_state.project_count = platform_state.project_count.checked_add(1).unwrap();: Uses checked arithmetic so overflow fails instead of wrapping. - Line 57
msg!("Project created: {} by {}", project.id, project.authority);: Logs to the program log, which is visible in explorers and the test output.
solana-program/openbudget/programs/openbudget/src/instructions/add_milestone.rs L1–23 @ cf76dde · MIT · originaluse 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>,- Line 9
init,: Creates and pays for a new account. Space and payer must be specified. - 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. - Line 13
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
solana-program/openbudget/programs/openbudget/src/instructions/release_funds.rs L1–24 @ cf76dde · MIT · originaluse 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>,- 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. - Line 11
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - 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.
| Directory | Command | Runs |
|---|---|---|
solana-program/openbudget | npm run lint | prettier */*.js "*/**/*{.js,.ts}" --check |
frontend | npm run dev | next dev |
frontend | npm run start | next start |
frontend | npm run build | next build |
frontend | npm run lint | next lint |
solana-program/openbudget | anchor build | compile programs and generate IDLs |
solana-program/openbudget | anchor test | local validator + test suite |
solana-program/openbudget | anchor run test | yarn run ts-mocha -p ./tsconfig.json -t 1000000 \ |
What you could build from it
- Fork the SuperStack copy and extend it within the Governance & DAOs 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: Anchor account constraints