Full lesson
BioMint-
Verifiable Clinical Data Exchange
What it does
From the project README:
A decentralised micropayment hub on Solana where patients tokenise their health data and get paid automatically — only when their data provably improves a buyer's AI model. A standalone oracle agent signs every evaluation with Ed25519. No signature, no payment.
- Original
- Shirosaru/BioMint-
- SuperStack fork
- Blockchains/BioMint- @
3479156 - Stars
- 0
- Last push (original)
- 2026-05-25
- Languages
- JavaScript, HTML, Rust, Shell
- Detected stack
- Anchorweb3.js
- Categories
- Infrastructure & Tooling
- Licence
- MIT
Architecture
29 source files. By extension: .js ×27, .rs ×2.
| Top-level directory | Source files |
|---|---|
src | 26 |
programs | 2 |
tests | 1 |
On-chain programs: programs/data-market, programs/policy-registry
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/biomint-/. 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.
programs/policy-registry/src/lib.rs L37–60 @ 3479156 · MIT · original state.max_ltv_bps = max_ltv_bps; state.mint_cap_usd = mint_cap_usd; state.version = state.version.checked_add(1).unwrap(); state.updated_at = Clock::get()?.unix_timestamp; Ok(()) }} #[derive(Accounts)]pub struct Initialize<'info> { #[account(mut)] pub admin: Signer<'info>, #[account( init, payer = admin, space = 8 + PolicyState::LEN, seeds = [b"policy-state", admin.key().as_ref()], bump )] pub policy_state: Account<'info, PolicyState>, pub system_program: Program<'info, System>,} #[derive(Accounts)]- Line 39
state.version = state.version.checked_add(1).unwrap();: Uses checked arithmetic so overflow fails instead of wrapping. - Line 40
state.updated_at = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 48
pub admin: Signer<'info>,: Requires this account to have signed the transaction. - Line 50
init,: Creates and pays for a new account. Space and payer must be specified. - Line 53
seeds = [b"policy-state", admin.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 54
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
programs/data-market/src/lib.rs L121–144 @ 3479156 · MIT · original record.evaluation_count = record.evaluation_count.checked_add(1).unwrap_or(u32::MAX); record.improvement_count = record.improvement_count.checked_add(1).unwrap_or(u32::MAX); emit!(ImprovementSettled { dataset_record: ctx.accounts.dataset_record.key(), buyer: ctx.accounts.buyer.key(), contributor: ctx.accounts.contributor.key(), delta_bps, payment_lamports, timestamp: Clock::get()?.unix_timestamp, }); Ok(()) } // ── No-improvement recording ───────────────────────────────────────────── /// Record an evaluation where the dataset did NOT improve the model. /// /// No payment occurs. This still updates on-chain stats so buyers can /// see the evaluation-to-improvement ratio of a listing. pub fn record_no_improvement(ctx: Context<RecordEvaluation>) -> Result<()> { let record = &mut ctx.accounts.dataset_record; require!(record.status == ListingStatus::Listed, DataMarketError::NotListed);- Line 121
record.evaluation_count = record.evaluation_count.checked_add(1).unwrap_or(u32::MAX);: Uses checked arithmetic so overflow fails instead of wrapping. - Line 124
emit!(ImprovementSettled {: Emits an Anchor event that clients can parse from the logs. - Line 130
timestamp: Clock::get()?.unix_timestamp,: Reads on-chain time from the Clock sysvar. - Line 144
require!(record.status == ListingStatus::Listed, DataMarketError::NotListed);: An explicit validation that aborts the instruction with an error.
src/x402Client.js L49–72 @ 3479156 · MIT · original} /** * Build and sign a Solana SOL transfer for an x402 payment requirement. * * @param {object} requirement - { payTo, maxAmountRequired, asset, network } * @param {Keypair} payer * @param {Connection} connection * @returns {Promise<string>} Base64-encoded signed transaction */async function buildX402Payment(requirement, payer, connection) { const { payTo, maxAmountRequired } = requirement; // maxAmountRequired is in lamports for SVM networks const amountLamports = Number(maxAmountRequired); const recipient = new PublicKey(payTo); const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("finalized"); const tx = new Transaction({ feePayer: payer.publicKey, blockhash, lastValidBlockHeight }).add(- Line 52
* Build and sign a Solana SOL transfer for an x402 payment requirement.: Uses x402, an HTTP 402 pattern where an agent pays per request with an on-chain payment. - Line 66
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("finalized: Fetches a recent blockhash. Transactions expire if it gets too old.
src/swapExecutor.js L145–167 @ 3479156 · MIT · original if (!swapRes.ok) { const txt = await swapRes.text(); return { skipped: false, error: `Jupiter swap error ${swapRes.status}: ${txt.slice(0, 200)}` }; } const { swapTransaction } = await swapRes.json(); // ── 3. Sign + send ────────────────────────────────────────────────────── const connection = new Connection(rpcUrl, "confirmed"); const txBuf = Buffer.from(swapTransaction, "base64"); const tx = VersionedTransaction.deserialize(txBuf); tx.sign([admin]); const signature = await connection.sendTransaction(tx, { skipPreflight: false, maxRetries: 3 }); const latest = await connection.getLatestBlockhash(); await connection.confirmTransaction( { signature, blockhash: latest.blockhash, lastValidBlockHeight: latest.lastValidBlockHeight }, "confirmed" );- Line 158
const signature = await connection.sendTransaction(tx, {: Submits the signed transaction to the cluster. - Line 163
const latest = await connection.getLatestBlockhash();: Fetches a recent blockhash. Transactions expire if it gets too old.
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 |
|---|---|---|
. | anchor build | compile programs and generate IDLs |
. | anchor test | local validator + test suite |
. | anchor run test | node tests/policy_registry.test.js |
. | cargo build | Rust workspace build |
. | cargo test | Rust tests |
What you could build from it
- Fork the SuperStack copy and extend it within the Infrastructure & Tooling gaps listed on the idea page.
- Learn the pattern first: Building and sending transactions from a client
- Learn the pattern first: Anchor account constraints