Sol.College

Full lesson

AutoShieldFI

What it does

From the project README:

AutoShieldFI é um dApp (aplicativo descentralizado) focado em proteção veicular para o mercado brasileiro. Nosso objetivo é oferecer uma alternativa acessível, eficiente e transparente ao seguro veicular tradicional por meio de infraestrutura Web3, proporcionando uma melhor experiência ao usuário e a possibilidade de retorno financeiro quando a cobertura não é utilizada.
Original
bl4cks1d3/AutoShieldFI
SuperStack fork
Blockchains/AutoShieldFI @ e207f10
Stars
0
Last push (original)
2026-10-01
Languages
TypeScript, Rust, CSS, JavaScript, HTML
Detected stack
@solana/kitAnchorNext.jsweb3.js
Categories
Other
Licence
Apache-2.0
Homepage
https://autoshieldfi.vercel.app

Architecture

69 source files. By extension: .ts ×34, .tsx ×21, .rs ×13, .js ×1.

Top-level directorySource files
app52
programs13
scripts3
tests1

On-chain programs: programs/autoshield

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

bl4cks1d3/AutoShieldFI · programs/autoshield/src/instructions/admin.rs L97–120 @ e207f10 · Apache-2.0 · original
/// Qualquer pessoa pode aplicar uma mudanca cujo timelock ja expirou.#[derive(Accounts)]pub struct ApplyGovernance<'info> {    pub caller: Signer<'info>,     #[account(mut, seeds = [POOL_SEED], bump = pool.bump)]    pub pool: Account<'info, Pool>,} pub fn propose_params(ctx: Context<AdminAction>, params: PoolParams) -> Result<()> {    require!(params.validate(), AutoShieldError::InvalidParameter);    let now = Clock::get()?.unix_timestamp;    let pool = &mut ctx.accounts.pool;    let eta = now        .checked_add(pool.params.governance_delay_secs)        .ok_or(AutoShieldError::MathOverflow)?;    pool.pending_params = Some(params);    pool.pending_params_eta = eta;    emit!(GovernanceChangeProposed { kind: 0, eta });    Ok(())} pub fn apply_params(ctx: Context<ApplyGovernance>) -> Result<()> {    let now = Clock::get()?.unix_timestamp;
  1. Line 100 pub caller: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 102 #[account(mut, seeds = [POOL_SEED], bump = pool.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 102 #[account(mut, seeds = [POOL_SEED], bump = pool.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 107 require!(params.validate(), AutoShieldError::InvalidParameter);: An explicit validation that aborts the instruction with an error.
  5. Line 108 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  6. Line 111 .checked_add(pool.params.governance_delay_secs): Uses checked arithmetic so overflow fails instead of wrapping.
  7. Line 115 emit!(GovernanceChangeProposed { kind: 0, eta });: Emits an Anchor event that clients can parse from the logs.
bl4cks1d3/AutoShieldFI · programs/autoshield/src/instructions/bond.rs L25–48 @ e207f10 · Apache-2.0 · original
     #[account(        init_if_needed,        payer = assessor,        space = 8 + AssessorRecord::INIT_SPACE,        seeds = [ASSESSOR_SEED, assessor.key().as_ref()],        bump    )]    pub assessor_record: Box<Account<'info, AssessorRecord>>,     pub token_program: Program<'info, Token>,    pub system_program: Program<'info, System>,} pub fn post_bond(ctx: Context<AssessorBond>, amount: u64) -> Result<()> {    require!(amount > 0, AutoShieldError::ZeroAmount);    token::transfer_checked(        CpiContext::new(            ctx.accounts.token_program.to_account_info(),            TransferChecked {                from: ctx.accounts.assessor_token.to_account_info(),                mint: ctx.accounts.stable_mint.to_account_info(),                to: ctx.accounts.vault.to_account_info(),                authority: ctx.accounts.assessor.to_account_info(),
  1. Line 27 init_if_needed,: Creates the account only if it doesn't exist. Watch for re-initialisation bugs.
  2. Line 30 seeds = [ASSESSOR_SEED, assessor.key().as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 31 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 40 require!(amount > 0, AutoShieldError::ZeroAmount);: An explicit validation that aborts the instruction with an error.
  5. Line 41 token::transfer_checked(: A checked token transfer, which also verifies the mint and decimals.
  6. Line 41 token::transfer_checked(: An SPL token transfer through the Token Program.
  7. Line 42 CpiContext::new(: Makes a cross-program invocation into another program.
bl4cks1d3/AutoShieldFI · programs/autoshield/src/instructions/claims.rs L361–384 @ e207f10 · Apache-2.0 · original
pub struct ExpireClaim<'info> {    pub caller: Signer<'info>,     #[account(mut, seeds = [POOL_SEED], bump = pool.bump)]    pub pool: Account<'info, Pool>,     #[account(mut, has_one = pool, address = claim.policy)]    pub policy: Box<Account<'info, Policy>>,     #[account(mut, has_one = pool, has_one = policy)]    pub claim: Box<Account<'info, Claim>>,} pub fn expire_claim(ctx: Context<ExpireClaim>) -> Result<()> {    let now = Clock::get()?.unix_timestamp;    let claim = &mut ctx.accounts.claim;    require!(        matches!(claim.status, ClaimStatus::Pending | ClaimStatus::Appealed),        AutoShieldError::ClaimNotPending    );    require!(now > claim.voting_deadline, AutoShieldError::VotingStillOpen);    claim.status = ClaimStatus::Rejected;    claim.resolved_ts = now;    let pool = &mut ctx.accounts.pool;
  1. Line 362 pub caller: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 364 #[account(mut, seeds = [POOL_SEED], bump = pool.bump)]: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  3. Line 364 #[account(mut, seeds = [POOL_SEED], bump = pool.bump)]: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
  4. Line 367 #[account(mut, has_one = pool, address = claim.policy)]: Checks that a stored pubkey field matches the passed account.
  5. Line 375 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  6. Line 377 require!(: An explicit validation that aborts the instruction with an error.
bl4cks1d3/AutoShieldFI · programs/autoshield/src/instructions/policy.rs L325–348 @ e207f10 · Apache-2.0 · original
     #[account(mut, has_one = pool, has_one = owner @ AutoShieldError::Unauthorized)]    pub policy: Box<Account<'info, Policy>>,     pub token_program: Program<'info, Token>,} /// Paga a proxima parcela. So e aceita ate o fim da tolerancia: depois disso a/// apolice caducou (evita pagar so depois do acidente).pub fn pay_installment(ctx: Context<PayInstallment>) -> Result<()> {    let now = Clock::get()?.unix_timestamp;    let grace = ctx.accounts.pool.params.installment_grace_secs;    let policy = &ctx.accounts.policy;    require!(        policy.status == PolicyStatus::Active,        AutoShieldError::PolicyNotActive    );    require!(!policy.fully_paid(), AutoShieldError::AlreadyFullyPaid);    require!(!policy.is_lapsed(now, grace), AutoShieldError::PolicyLapsed);    let amount = policy.next_installment_amount();     token::transfer_checked(        CpiContext::new(            ctx.accounts.token_program.to_account_info(),
  1. Line 326 #[account(mut, has_one = pool, has_one = owner @ AutoShieldError::Unauthorized)]: Checks that a stored pubkey field matches the passed account.
  2. Line 335 let now = Clock::get()?.unix_timestamp;: Reads on-chain time from the Clock sysvar.
  3. Line 338 require!(: An explicit validation that aborts the instruction with an error.
  4. Line 346 token::transfer_checked(: A checked token transfer, which also verifies the mint and decimals.
  5. Line 346 token::transfer_checked(: An SPL token transfer through the Token Program.
  6. Line 347 CpiContext::new(: Makes a cross-program invocation into another program.

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
appnpm run devnext dev
appnpm run startnext start
appnpm run buildnext build
appnpm run linttsc --noEmit
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run bootstrapyarn run ts-node scripts/bootstrap.ts
.anchor run oracleyarn run ts-node scripts/oracle-fipe.ts
.anchor run shopyarn run ts-node scripts/register-shop.ts
.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

Used in lessons