Sol.College

Full lesson

WorkChain

Payment protocol for AI agents on Solana - condition-based escrow with AI verification

What it does

From the project README:

[](https://opensource.org/licenses/MIT) [](https://explorer.solana.com/) [](https://www.anchor-lang.com/) []() [](https://workchain-protocol.vercel.app) [](https://workchain-production.up.railway.app/health)
Original
adityachotaliya9299-jpg/WorkChain
SuperStack fork
Blockchains/WorkChain @ 04e8902
Stars
1
Last push (original)
2026-06-30
Languages
TypeScript, Rust, CSS, JavaScript
Detected stack
AnchorNext.jsweb3.js
Categories
AI & AgentsDeFi
Licence
MIT
Homepage
https://work-chain-flame.vercel.app

Architecture

51 source files. By extension: .ts ×23, .tsx ×17, .rs ×10, .js ×1.

Top-level directorySource files
frontend20
verifier14
programs10
tests2
docs1
migrations1
sdk1
subgraph1

On-chain programs: programs/workchain

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/workchain/. 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.

adityachotaliya9299-jpg/WorkChain · programs/workchain/src/instructions/dispute_work_order.rs L25–48 @ 04e8902 · MIT · original
     emit!(WorkOrderDisputed {        work_order:  ctx.accounts.work_order.key(),        client:      ctx.accounts.client.key(),        disputed_at: clock.unix_timestamp,    });     Ok(())} #[derive(Accounts)]pub struct DisputeWorkOrder<'info> {    pub client: Signer<'info>,     #[account(        mut,        seeds = [            b"work_order",            client.key().as_ref(),            work_order.condition_hash.as_ref()        ],        bump  = work_order.bump,        has_one = client @ WorkChainError::UnauthorizedClient,    )]
  1. Line 26 emit!(WorkOrderDisputed {: Emits an Anchor event that clients can parse from the logs.
  2. Line 29 disputed_at: clock.unix_timestamp,: Reads on-chain time from the Clock sysvar.
  3. Line 37 pub client: Signer<'info>,: Requires this account to have signed the transaction.
  4. Line 41 seeds = [: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  5. Line 46 bump = work_order.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  6. Line 47 has_one = client @ WorkChainError::UnauthorizedClient,: Checks that a stored pubkey field matches the passed account.
adityachotaliya9299-jpg/WorkChain · programs/workchain/src/instructions/register_verifier.rs L25–48 @ 04e8902 · MIT · original
    record.verifier      = ctx.accounts.verifier.key();    record.name          = name;    record.stake         = VerifierRecord::MIN_STAKE;    record.jobs_completed = 0;    record.jobs_disputed  = 0;    record.registered_at  = clock.unix_timestamp;    record.is_active      = true;    record.bump           = ctx.bumps.verifier_record;     emit!(VerifierRegistered {        verifier:      ctx.accounts.verifier.key(),        registered_at: clock.unix_timestamp,    });     Ok(())} #[derive(Accounts)]pub struct RegisterVerifier<'info> {    #[account(mut)]    pub verifier: Signer<'info>,     #[account(        init,
  1. Line 27 record.stake = VerifierRecord::MIN_STAKE;: Touches staking state: the amount locked and when it was locked.
  2. Line 30 record.registered_at = clock.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  3. Line 32 record.bump = ctx.bumps.verifier_record;: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 34 emit!(VerifierRegistered {: Emits an Anchor event that clients can parse from the logs.
  5. Line 45 pub verifier: Signer<'info>,: Requires this account to have signed the transaction.
  6. Line 48 init,: Creates and pays for a new account. Space and payer must be specified.
adityachotaliya9299-jpg/WorkChain · programs/workchain/src/instructions/complete_work_order.rs L85–108 @ 04e8902 · MIT · original
        completed_at:   clock.unix_timestamp,        proof,    });     Ok(())} #[derive(Accounts)]pub struct CompleteWorkOrder<'info> {    pub verifier: Signer<'info>,     #[account(        mut,        seeds = [            b"work_order",            work_order.client.as_ref(),            work_order.condition_hash.as_ref()        ],        bump  = work_order.bump,        has_one = verifier @ WorkChainError::UnauthorizedVerifier,    )]    pub work_order: Account<'info, WorkOrder>,     #[account(
  1. Line 85 completed_at: clock.unix_timestamp,: Reads on-chain time from the Clock sysvar.
  2. Line 94 pub verifier: Signer<'info>,: Requires this account to have signed the transaction.
  3. Line 98 seeds = [: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  4. Line 103 bump = work_order.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  5. Line 104 has_one = verifier @ WorkChainError::UnauthorizedVerifier,: Checks that a stored pubkey field matches the passed account.
adityachotaliya9299-jpg/WorkChain · programs/workchain/src/instructions/create_work_order.rs L73–96 @ 04e8902 · MIT · original
        recipient:      params.recipient,        verifier:       params.verifier,        payment_amount: params.payment_amount,        protocol_fee,        deadline:       params.deadline,        created_at:     clock.unix_timestamp,    });     Ok(())} #[derive(Accounts)]#[instruction(params: CreateWorkOrderParams)]pub struct CreateWorkOrder<'info> {    #[account(mut)]    pub client: Signer<'info>,     #[account(        init,        payer = client,        space = WorkOrder::LEN,        seeds = [b"work_order", client.key().as_ref(), params.condition_hash.as_ref()],        bump    )]
  1. Line 78 created_at: clock.unix_timestamp,: Reads on-chain time from the Clock sysvar.
  2. Line 88 pub client: Signer<'info>,: Requires this account to have signed the transaction.
  3. Line 91 init,: Creates and pays for a new account. Space and payer must be specified.
  4. Line 94 seeds = [b"work_order", client.key().as_ref(), params.condition_hash.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  5. Line 95 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.

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 lintprettier */*.js "*/**/*{.js,.ts}" --check
sdknpm run devtsc --watch
sdknpm run buildtsc
frontendnpm run devnext dev
frontendnpm run startnext start
frontendnpm run buildnext build
frontendnpm run lintnext lint
verifiernpm run devnodemon --exec ts-node src/index.ts
verifiernpm run startnode dist/index.js
verifiernpm run buildtsc && mkdir -p dist/idl && cp src/idl/workchain.json dist/idl/workchain.json
verifiernpm run testts-mocha -p ./tsconfig.json -t 10000 src/tests/**/*.test.ts
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testyarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it