← B2 Apps StoreAll Guides

Solana Smart Contract Starter Checklist: Project Structure, Testing & Pre-Audit Steps

Published 2026-11-19 · B2 Apps Technical Guides

Key Takeaways

---

1. Initialize a Clean Workspace with Anchor

A reproducible Solana smart contract boilerplate starts with Anchor v0.29+. Run `anchor init <project-name>` to generate the canonical structure:

```text

/programs/<project-name>/src/lib.rs // On-chain logic

/tests/<project-name>.ts // TypeScript integration tests

/app/ // Optional: React/Next.js client SDK

/Anchor.toml // Cluster config & program IDs

/migrations/ // Deploy scripts (optional)

```

Why it matters: This layout separates consensus-critical code from off-chain tooling, making it easier for auditors to scope the review. Keep `lib.rs` lean—delegate instruction handlers to modules under `src/instructions/` and state definitions to `src/state/`.

---

2. Enforce Code Quality Gates Locally

Before pushing to CI, run the Rust toolchain’s built-in checks and Solana-specific linters:

```bash

cargo fmt --all -- --check

cargo clippy --workspace -- -D warnings

cargo audit

cargo test-sbf -- --nocapture

```

Add a `.pre-commit-config.yaml` or GitHub Actions workflow to block merges that fail these steps. This satisfies the baseline hygiene expected in any Web3 developer starter kit and reduces audit finding noise.

---

3. Layer Testing: Unit → Integration → Fuzzing

| Layer | Tool | Scope |

|-------|------|-------|

| Unit | `#[test]` in Rust | Pure logic (math, PDA derivation, state transitions) without runtime. |

| Integration | `solana-test-validator` + TypeScript (Mocha/Jest) | Full transaction lifecycle: rent, CPI, account resizing, clock sysvar. |

| Fuzzing/Property | `trident-fuzz` or `proptest` | Invariant checking (e.g., "total supply never exceeds minted"). |

Practical tip: Use Bankrun (`solana-bankrun`) for deterministic, parallelizable integration tests that don’t require a local validator process. It cuts CI runtime by 60–80% compared to `solana-test-validator`.

---

4. Pre-Audit Checklist: Close the Low-Hanging Fruit

Auditors charge premium rates for findings you can catch in 30 minutes. Complete these before signing an engagement letter:

1. Integer Safety: Replace all `+`/`-`/`*` with `checked_*` or `saturating_*`; use `anchor_lang::prelude::*` safe math traits.

2. Account Validation: Every `#[account]` struct implements `AccountDeserialize` + `AccountSerialize`; enforce `has_one` / `constraint` checks on cross-program invocations.

3. Signer & Authority Checks: Verify `Signer` constraints on all mutating instructions; ensure `mint_authority` and `freeze_authority` are set to `None` or a multisig *before* mainnet deploy.

4. Token-2022 Compliance: If using extensions (confidential transfers, transfer hooks), run `spl-token-2022` CLI simulations against your program ID.

5. Event & Log Hygiene: Emit typed events (`#[event]`) for all state changes; avoid `msg!` for critical data—indexers rely on events.

---

5. Token Sale & Launch Readiness (The "Go/No-Go" Gate)

If your program handles a token sale, vesting, or liquidity bootstrapping, treat this as a distinct workstream. A Solana token sale checklist should cover:

---

Practical 5-Step Starter Checklist

1. Scaffold: `anchor init` → modularize `src/` into `instructions/`, `state/`, `errors/`, `events/`.

2. Hardening: Enable `cargo clippy -D warnings`, `cargo audit`, `cargo fmt

Try the matching utility:
Solana & Web3 Starter Kits & self-contained digital kits
Open Solana & Web3 Starter Kits →
Disclaimer: Educational and planning information only; not financial, investment, tax, or legal advice.