Full lesson
AssetFlow
The servicing layer for tokenized bonds and funds: who may hold them, what each holder is owed on the record date, and how they redeem. Solidity on Arbitrum, Robinhood Chain and Base, paid in Paxos USDG, and native on Solana.
What it does
From the project README:
Issuance is day one. A tokenized bond or fund still has to be run every day after: holder eligibility, transfer restrictions, coupons and dividends, redemptions, maturity. Today that work lives in spreadsheets and email next to a token on-chain. AssetFlow puts it where the token is.
- Original
- N-45div/AssetFlow
- SuperStack fork
- Blockchains/AssetFlow @
1995793 - Stars
- 0
- Last push (original)
- 2026-10-11
- Languages
- TypeScript, Rust, JavaScript, Solidity, Shell, CSS
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- Other
- Licence
- MIT
- Homepage
- https://assetflow-servicing.vercel.app
Architecture
150 source files. By extension: .tsx ×61, .ts ×51, .sol ×19, .js ×13, .rs ×6.
| Top-level directory | Source files |
|---|---|
frontend | 103 |
solana | 15 |
contracts | 15 |
evm | 9 |
backend | 8 |
On-chain programs: solana/programs/assetflow
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/assetflow/. 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/assetflow/src/coupons.rs L493–516 @ 1995793 · MIT · original payout.private_paid = true; emit!(PrivatePoolPaid { asset: payout.asset, period, units: payout.private_units, amount }); Ok(())} pub fn release_marker(ctx: Context<ReleaseCounted>) -> Result<()> { require!(ctx.accounts.payout.status == PayoutStatus::Counted, AssetFlowError::WrongPayoutStatus); Ok(())} #[derive(Accounts)]pub struct SetTerms<'info> { #[account(mut)] pub issuer: Signer<'info>, #[account(has_one = issuer @ AssetFlowError::Unauthorized)] pub asset: Account<'info, Asset>, pub currency_mint: InterfaceAccount<'info, Mint>, #[account( init, payer = issuer, space = 8 + Terms::INIT_SPACE, seeds = [TERMS_SEED, asset.mint.as_ref()], bump )]- Line 494
emit!(PrivatePoolPaid { asset: payout.asset, period, units: payout.private_units, amount }: Emits an Anchor event that clients can parse from the logs. - Line 499
require!(ctx.accounts.payout.status == PayoutStatus::Counted, AssetFlowError::WrongPayoutS: An explicit validation that aborts the instruction with an error. - Line 506
pub issuer: Signer<'info>,: Requires this account to have signed the transaction. - Line 507
#[account(has_one = issuer @ AssetFlowError::Unauthorized)]: Checks that a stored pubkey field matches the passed account. - Line 511
init,: Creates and pays for a new account. Space and payer must be specified. - Line 514
seeds = [TERMS_SEED, asset.mint.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 515
bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
solana/programs/assetflow/src/redemptions.rs L229–252 @ 1995793 · MIT · original emit!(RedemptionRequested { asset, holder, id, units }); Ok(())} pub fn settle_request(ctx: Context<SettleRedemption>) -> Result<()> { let a = &ctx.accounts; require!(a.request.status == RedemptionStatus::Requested, AssetFlowError::RequestClosed); require!(!is_matured(&a.mint), AssetFlowError::AssetMatured); require!(!mint_supply_and_paused(&a.mint.to_account_info())?.1, AssetFlowError::MintPaused); require!( holder_is_eligible(&a.asset.key(), &a.registry, &a.request.holder, &a.investor.to_account_info())?, AssetFlowError::NotEligible ); let now = Clock::get()?.unix_timestamp; let units = a.request.units; let face = principal(a.terms.face_per_unit, units)?; let accrued = accrued_interest(&a.terms, units, now)?; let amount = face.checked_add(accrued).ok_or(error!(AssetFlowError::MathOverflow))?; // Delivery against payment: the cash moves and the units burn together. token_interface::transfer_checked( CpiContext::new( a.currency_program.key(), TransferChecked {- Line 229
emit!(RedemptionRequested { asset, holder, id, units });: Emits an Anchor event that clients can parse from the logs. - Line 235
require!(a.request.status == RedemptionStatus::Requested, AssetFlowError::RequestClosed);: An explicit validation that aborts the instruction with an error. - Line 242
let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar. - Line 246
let amount = face.checked_add(accrued).ok_or(error!(AssetFlowError::MathOverflow))?;: Uses checked arithmetic so overflow fails instead of wrapping. - Line 249
token_interface::transfer_checked(: A checked token transfer, which also verifies the mint and decimals. - Line 250
CpiContext::new(: Makes a cross-program invocation into another program.
solana/programs/assetflow/src/kyc.rs L193–216 @ 1995793 · MIT · original} pub fn lapse(ctx: Context<LapseProfile>) -> Result<()> { let wallet = ctx.accounts.marker.wallet; let info = ctx.accounts.attestation.to_account_info(); // A closed account, or anything SAS no longer holds there, vouches for nobody. let still = !info.data_is_empty() && read_attestation(&info) .map(|a| vouches(&a, &ctx.accounts.source, &wallet, Clock::get().map(|c| c.unix_timestamp).unwrap_or(0))) .unwrap_or(false); require!(!still, AssetFlowError::StillAttested); ctx.accounts.investor.approved = false; emit!(ProfileLapsed { registry: ctx.accounts.registry.key(), wallet, attestation: info.key() }); Ok(())} #[derive(Accounts)]pub struct SetKycSource<'info> { #[account(mut)] pub compliance: Signer<'info>, #[account(has_one = compliance @ AssetFlowError::Unauthorized)] pub registry: Account<'info, Registry>, #[account( init_if_needed,- Line 201
.map(|a| vouches(&a, &ctx.accounts.source, &wallet, Clock::get().map(|c| c.unix_timestamp): Reads on-chain time from the Clock sysvar. - Line 203
require!(!still, AssetFlowError::StillAttested);: An explicit validation that aborts the instruction with an error. - Line 205
emit!(ProfileLapsed { registry: ctx.accounts.registry.key(), wallet, attestation: info.key: Emits an Anchor event that clients can parse from the logs. - Line 212
pub compliance: Signer<'info>,: Requires this account to have signed the transaction. - Line 213
#[account(has_one = compliance @ AssetFlowError::Unauthorized)]: Checks that a stored pubkey field matches the passed account. - Line 216
init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
solana/programs/assetflow/src/lib.rs L769–792 @ 1995793 · MIT · original return Ok(false); } let profile = InvestorProfile::try_deserialize(&mut &investor.try_borrow_data()?[..])?; Ok(registry.admits(&profile, Clock::get()?.unix_timestamp))} #[derive(Accounts)]pub struct CreateRegistry<'info> { #[account(mut)] pub admin: Signer<'info>, #[account( init, payer = admin, space = 8 + Registry::INIT_SPACE, seeds = [REGISTRY_SEED, admin.key().as_ref()], bump )] pub registry: Account<'info, Registry>, pub system_program: Program<'info, System>,} #[derive(Accounts)]pub struct RegistryAdmin<'info> { pub admin: Signer<'info>,- Line 772
Ok(registry.admits(&profile, Clock::get()?.unix_timestamp)): Reads on-chain time from the Clock sysvar. - Line 778
pub admin: Signer<'info>,: Requires this account to have signed the transaction. - Line 780
init,: Creates and pays for a new account. Space and payer must be specified. - Line 783
seeds = [REGISTRY_SEED, admin.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 784
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.
| Directory | Command | Runs |
|---|---|---|
backend | npm run dev | node --watch src/server.js |
backend | npm run start | node src/server.js |
backend | npm run test | node --test |
frontend | npm run dev | next dev |
frontend | npm run start | next start |
frontend | npm run build | next build --webpack |
frontend | npm run lint | eslint |
evm | npm run build | forge build |
evm | npm run test | forge test |
solana | npm run test | mocha --require ts-node/register --timeout 300000 tests/*.test.ts |
contracts | npm run test | npm run compile && hardhat test --no-compile |
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)