A suite of Anchor programs for the Trusted Auto Data (TAD) platform on Solana – Car registration, dealer & user on-chain profiles – Odometer (km) tracking & error reporting – Service NFT minting tied to car state – Points & reward system
.
├── Anchor.toml
├── programs/
│ └── tad_contracts/ # Anchor Rust program
│ ├── src/
│ │ ├── instructions/ # init_car, init_config, init_dealer, init_user, register_km, report_error, register_service, add_points
│ │ ├── state/ # account definitions: Car, Config, Dealer, User, ReportData
│ │ ├── events/ # KmRegistered, ErrorReported
│ │ └── lib.rs # program entrypoints
│ └── Cargo.toml
├── tests/
│ └── tad_contracts.ts # mo paralle tests for all instructions
├── tsconfig.json
└── package.json # dev & test dependencies
- Rust & Cargo
- Solana CLI (v1.13+)
- Anchor CLI (v0.29+)
- Node.js & Yarn (for tests)
# Clean slate + load Metaplex CPIs for service-NFT minting
solana-test-validator \
-r \
--bpf-program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s dump_programs/metaplex_token_metadata_program.so \
--bpf-program CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d dump_programs/metaplex_core_program.so
# Build your program
anchor build
# Deploy to localnet
anchor deploy --provider.cluster localnet
Your
Anchor.toml
will be automatically updated with the deployed program ID.
yarn install
anchor test
This script:
- Starts the validator (with Metaplex CPIs)
- Builds & deploys
tad_contracts
- Runs the mocha tests in
tests/tad_contracts.ts
-
Initialize Config Creates a
Config
PDA holding your admin key. -
Initialize Dealer & User Stores on-chain profiles under PDAs
[b"dealer", authority]
and[b"user", authority]
. -
Initialize Car PDA
[b"car", vin]
storesvin
,owner
,dealer
, and bump. Trackstotal_km
, allows external backends to sign KM updates. -
Register KM & Report Errors Cpi-free instructions to bump
car.total_km
or emit an on-chain logErrorReported
. -
Register Service Mints a Metaplex NFT (
CreateV2Cpi
) to the car owner, embedding VIN, total_km, and report_type as on-chain attributes. Saves metadata inReportData
PDA. -
Add Points to User Admin-only instruction to increment on-chain
User.points
.
- Anchor.toml
Ensure
[program.tad_contracts]
matches your deployed ID. - Environment
If you integrate with Pinata or other IPFS, add your
.env
with any JWT / gatew 5F3B ay settings for metadata uploads in tests.