Full lesson
ExplorerChem
What it does
From the project README:
ExploreChem lets a rare-earth producer prove where a lot came from and how its mass was accounted for, without revealing volumes, grades or capacity to competitors, and then use that verified lot as collateral for export financing. Private industrial evidence is processed by Chainlink CRE (Chainlink Runtime Environment) workflows; Ethereum Sepolia records lot commitments, custody states and lineage; Solana Devnet records an issuer-linked economic right (RWA, Real World Asset) that a financier funds and the issuer settles.
- Original
- armanfm/ExplorerChem
- SuperStack fork
- Blockchains/ExplorerChem @
a97dd52 - Stars
- 2
- Last push (original)
- 2026-10-31
- Languages
- HTML, TypeScript, Rust, Solidity
- Detected stack
- Anchorweb3.js
- Categories
- Infrastructure & Tooling
- Licence
- Apache-2.0
Architecture
26 source files. By extension: .rs ×15, .ts ×7, .sol ×4.
| Top-level directory | Source files |
|---|---|
solana | 17 |
workflows | 5 |
contracts | 4 |
On-chain programs: solana/programs/explorechem-rwa-solana
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/explorerchem/. 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/programs/explorechem-rwa-solana/src/instructions/marketplace.rs L1–24 @ a97dd52 · Apache-2.0 · originaluse anchor_lang::prelude::*;use anchor_lang::system_program;use anchor_spl::{associated_token::AssociatedToken, token_2022::{self, Token2022, TransferChecked, CloseAccount}, token_interface::{Mint, TokenAccount}};use crate::state::*;use crate::error::ExploreChemRwaError as MarketError;#[derive(Accounts)]pub struct ListRwa<'info> { #[account(mut)] pub seller: Signer<'info>, #[account(seeds=[b"config"], bump=config.bump)] pub config: Box<Account<'info, Config>>, #[account(seeds=[b"series", series.series_id.as_ref()], bump=series.bump)] pub series: Box<Account<'info, Series>>, #[account(seeds=[b"rwa-mint", series.series_id.as_ref()], bump=mint_record.bump, constraint=mint_record.series_id==series.series_id, constraint=mint_record.mint==mint.key())] pub mint_record: Box<Account<'info, RwaMintRecord>>, #[account(address=mint_record.mint, constraint=mint.supply==1, constraint=mint.decimals==0)] pub mint: Box<InterfaceAccount<'info, Mint>>, #[account(mut, token::mint=mint, token::authority=seller, token::token_program=token_program, constraint=seller_token.amount==1)] pub seller_token: Box<InterfaceAccount<'info, TokenAccount>>, #[account(init, payer=seller, space=8+Listing::INIT_SPACE, seeds=[b"listing", series.series_id.as_ref()], bump)] pub listing: Box<Account<'info, Listing>>, #[account(mut, associated_token::mint=mint, associated_token::authority=listing, associated_token::token_program=token_program, constraint=escrow.amount==0)] pub escrow: Box<InterfaceAccount<'info, TokenAccount>>, pub token_program: Program<'info, Token2022>, pub associated_token_program: Program<'info, AssociatedToken>,- Line 3
use anchor_spl::{associated_token::AssociatedToken, token_2022::{self, Token2022, Transfer: A checked token transfer, which also verifies the mint and decimals. - Line 3
use anchor_spl::{associated_token::AssociatedToken, token_2022::{self, Token2022, Transfer: Targets the Token-2022 program instead of the original Token Program. - Line 8
#[account(mut)] pub seller: Signer<'info>,: Requires this account to have signed the transaction. - Line 9
#[account(seeds=[b"config"], bump=config.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 9
#[account(seeds=[b"config"], bump=config.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 19
#[account(init, payer=seller, space=8+Listing::INIT_SPACE, seeds=[b"listing", series.serie: Creates and pays for a new account. Space and payer must be specified.
solana/programs/explorechem-rwa-solana/src/instructions/cancel_rwa.rs L37–57 @ a97dd52 · Apache-2.0 · original #[account(mut, seeds=[b"credit-lineage-v2"], bump=lineage.bump)] pub lineage: Box<Account<'info, LineageRegistry>>, pub token_program: Program<'info, Token2022>,} pub fn handle_cancel_rwa(ctx: Context<CancelRwa>, history_hash: [u8;32]) -> Result<()> { require!(history_hash != [0;32], crate::error::ExploreChemRwaError::Invalid); ctx.accounts.lineage.require_reserved(ctx.accounts.series.series_id)?; token_2022::burn(CpiContext::new(ctx.accounts.token_program.key(), Burn { mint: ctx.accounts.mint.to_account_info(), from: ctx.accounts.holder_token.to_account_info(), authority: ctx.accounts.holder.to_account_info(), }), 1)?; ctx.accounts.series.economic_status = 3; ctx.accounts.lineage.release(ctx.accounts.series.series_id); emit!(RwaCancelled { series_id: ctx.accounts.series.series_id, mint: ctx.accounts.mint.key(), holder: ctx.accounts.holder.key(), history_hash }); Ok(())} #[event]pub struct RwaCancelled { pub series_id: [u8;32], pub mint: Pubkey, pub holder: Pubkey, pub history_hash: [u8;32] }- Line 37
#[account(mut, seeds=[b"credit-lineage-v2"], bump=lineage.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 37
#[account(mut, seeds=[b"credit-lineage-v2"], bump=lineage.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 39
pub token_program: Program<'info, Token2022>,: Targets the Token-2022 program instead of the original Token Program. - Line 43
require!(history_hash != [0;32], crate::error::ExploreChemRwaError::Invalid);: An explicit validation that aborts the instruction with an error. - Line 45
token_2022::burn(CpiContext::new(ctx.accounts.token_program.key(), Burn {: Makes a cross-program invocation into another program. - Line 51
emit!(RwaCancelled { series_id: ctx.accounts.series.series_id, mint: ctx.accounts.mint.key: Emits an Anchor event that clients can parse from the logs.
solana/programs/explorechem-rwa-solana/src/instructions/initialize.rs L73–96 @ a97dd52 · Apache-2.0 · original pub authority: Signer<'info>, #[account(mut, seeds = [b"config"], bump = config.bump, has_one = authority)] pub config: Account<'info, Config>,} pub fn handle_update_source_config( ctx: Context<UpdateSourceConfig>, source_chain_id: u64, source_lots_contract: [u8; 20],) -> Result<()> { require!(source_chain_id != 0, ExploreChemRwaError::InvalidSource); require!(source_lots_contract != [0u8; 20], ExploreChemRwaError::InvalidSource); let config = &mut ctx.accounts.config; emit!(SourceConfigUpdated { authority: config.authority, previous_chain_id: config.source_chain_id, previous_lots_contract: config.source_lots_contract, source_chain_id, source_lots_contract, }); config.source_chain_id = source_chain_id; config.source_lots_contract = source_lots_contract; Ok(())}- Line 73
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 74
#[account(mut, seeds = [b"config"], bump = config.bump, has_one = authority)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 74
#[account(mut, seeds = [b"config"], bump = config.bump, has_one = authority)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 74
#[account(mut, seeds = [b"config"], bump = config.bump, has_one = authority)]: Checks that a stored pubkey field matches the passed account. - Line 83
require!(source_chain_id != 0, ExploreChemRwaError::InvalidSource);: An explicit validation that aborts the instruction with an error. - Line 86
emit!(SourceConfigUpdated {: Emits an Anchor event that clients can parse from the logs.
solana/programs/explorechem-rwa-solana/src/instructions/usdt.rs L37–60 @ a97dd52 · Apache-2.0 · original ); } else { require_keys_eq!( config.payment_mint, OFFICIAL_USDT_MINT, ExploreChemRwaError::WrongPaymentMint ); } Ok(())} // Configuracao imutavel: atualizar o programa nao altera a moeda de ofertas existentes.#[derive(Accounts)]pub struct InitializeUsdtPayments<'info> { #[account(mut, address=config.authority @ ExploreChemRwaError::UnauthorizedPaymentAdmin)] pub authority: Signer<'info>, #[account(seeds=[b"config"], bump=config.bump)] pub config: Box<Account<'info, Config>>, #[account(init, payer=authority, space=8+UsdtPaymentConfig::INIT_SPACE, seeds=[b"usdt-payments"], bump)] pub payment_config: Box<Account<'info, UsdtPaymentConfig>>, #[account(constraint=payment_mint.decimals==USDT_DECIMALS @ ExploreChemRwaError::InvalidPaymentToken)] pub payment_mint: Box<Account<'info, token::Mint>>, pub payment_token_program: Program<'info, token::Token>, pub system_program: Program<'info, System>,- Line 39
require_keys_eq!(: An explicit validation that aborts the instruction with an error. - Line 52
pub authority: Signer<'info>,: Requires this account to have signed the transaction. - Line 53
#[account(seeds=[b"config"], bump=config.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 53
#[account(seeds=[b"config"], bump=config.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 55
#[account(init, payer=authority, space=8+UsdtPaymentConfig::INIT_SPACE, seeds=[b"usdt-paym: Creates and pays for a new account. Space and payer must be specified.
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 | anchor build | compile programs and generate IDLs |
solana | anchor test | local validator + test suite |
solana | anchor run test | yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/test_stage3.ts |
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