Full lesson
agroflux
Passaporte digital de recebíveis agrícolas com registro verificável na Solana Devnet — Colosseum Crypto World's Fair
What it does
From the project README:
Brazilian farm-input distributors (fertilizer, seed, crop protection) sell on credit, with payment at harvest. They need cash now, and funders (credit funds, banks, cooperatives) are willing to advance it, but every funder asks the same three questions before buying a receivable:
- Original
- wilgnnerdamas-hub/agroflux
- SuperStack fork
- Blockchains/agroflux @
ff3c6d9 - Stars
- 0
- Last push (original)
- 2026-10-22
- Languages
- TypeScript, JavaScript, Rust, CSS
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- Other
- Licence
- MIT
- Homepage
- https://agroflux-ruby.vercel.app
Architecture
121 source files. By extension: .ts ×82, .tsx ×38, .rs ×1.
| Top-level directory | Source files |
|---|---|
frontend | 61 |
backend | 58 |
blockchain | 2 |
On-chain programs: blockchain/programs/agroflux-escrow
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/agroflux/. 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.
blockchain/programs/agroflux-escrow/src/lib.rs L169–192 @ ff3c6d9 · MIT · original init_if_needed, payer = payer, associated_token::mint = settlement_mint, associated_token::authority = distributor, associated_token::token_program = settlement_token_program, )] pub distributor_settlement: Box<InterfaceAccount<'info, TokenAccount>>, /// Registro da liquidação. `init` falha se o token já foi liquidado. #[account( init, payer = payer, space = 8 + Settlement::INIT_SPACE, seeds = [SETTLEMENT_SEED, asset_mint.key().as_ref()], bump, )] pub settlement: Account<'info, Settlement>, /// Trava do documento (v1.2). `init` falha se o documento já foi cedido, mesmo com outro token. #[account( init, payer = payer, space = 8 + DocumentLock::INIT_SPACE, seeds = [DOCUMENT_SEED, document_hash.as_ref()],- Line 169
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs. - Line 179
init,: Creates and pays for a new account. Space and payer must be specified. - Line 182
seeds = [SETTLEMENT_SEED, asset_mint.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 183
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
backend/src/chain/assignment.ts L1–24 @ ff3c6d9 · MIT · original// Cessão tokenizada na Devnet (contrato v1.3, §6.4, §6.5 e §15.3). SIMULAÇÃO: token e moeda sem valor.// 1) Token da cessão: Token-2022, supply 1, decimals 0, metadados só com referência e payloadHash, mint revogado.// 2) Liquidação atômica pelo programa Anchor de escrow (blockchain/programs/agroflux-escrow), com trava por documento.import { AuthorityType, ExtensionType, LENGTH_SIZE, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, TYPE_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountIdempotentInstruction, createBurnCheckedInstruction, createInitializeMetadataPointerInstruction, createInitializeMintInstruction, createMintToInstruction, createSetAuthorityInstruction, getAssociatedTokenAddressSync, getMint, getMintLen, getTokenMetadata,} from "@solana/spl-token";import { createInitializeInstruction, createUpdateAuthorityInstruction, createUpdateFieldInstruction, pack, type TokenMetadata } from "@solana/spl-token-metadata";import { Connection, Keypair, PublicKey, SystemProgram, Transaction, TransactionInstruction, type Signer } from "@solana/web3.js";- Line 8
TOKEN_2022_PROGRAM_ID,: Targets the Token-2022 program instead of the original Token Program. - Line 16
createMintToInstruction,: Mints new tokens. The mint authority must sign.
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 |
|---|---|---|
blockchain | 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 | eslint |
backend | npm run dev | tsx watch src/server.ts |
backend | npm run start | tsx src/server.ts |
backend | npm run test | vitest run |
blockchain | anchor build | compile programs and generate IDLs |
blockchain | anchor test | local validator + test suite |
blockchain | 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 Other gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)