The seed script (src/scripts/seed.ts) populates the TruthBounty API database with realistic test data, enabling rapid development, testing, and demos without manual data entry.
Status: ✅ Fully functional and reliable
- Varying reputation levels (10-95)
- Simulates different user types:
- New users (reputation: 10)
- Regular contributors (reputation: 30-60)
- Experienced verifiers (reputation: 85)
- Expert verifiers (reputation: 95)
- Multi-chain wallet assignments
- Chains: Ethereum, Optimism, Polygon, Stellar
- Multiple wallets per user to test:
- Cross-chain scenarios
- Multiple wallet linking
- Chain-specific address formats
- Various resolution states:
- Resolved as TRUE (high confidence)
- Resolved as FALSE (moderate confidence)
- Unresolved (in review)
- New claims awaiting evidence
- Confidence scores ranging from 0.58 to 0.95
- Demonstrates different lifecycle stages
- Multiple evidence items per claim
- Version history tracking (1-3 versions per evidence)
- IPFS CID examples for distributed storage
- Simulates evidence revision history
- IPFS content hashes (CID):
- Version 1: Initial submission
- Version 2+: Revisions/updates
- Demonstrates how evidence evolves over time
Run the seed script with default settings:
npm run seedOutput:
🌱 Starting database seed...
✅ Database connection established
👥 Creating test users...
✅ Created 5 users
💼 Creating wallets...
✅ Created 11 wallets
📋 Creating sample claims...
✅ Created 5 claims
📄 Creating supporting evidence...
✅ Created 5 evidence entries
✅ Created 8 evidence versions
🎉 Seed completed successfully!
To remove all existing seed data and start fresh:
npm run seed -- --clearWhat this does:
- Clears all evidence versions
- Clears all evidence
- Clears all claims
- Clears all wallets
- Clears all users
- Creates fresh seed data
Warning: Use with caution in production. Only recommended for development/testing.
The seed script respects the following environment variables:
| Variable | Default | Purpose |
|---|---|---|
DATABASE_PATH |
database.sqlite |
Path to SQLite database file |
NODE_ENV |
(unset) | If set to 'production', synchronize is disabled |
# Optional: customize database path
DATABASE_PATH=./data/dev.sqlite
# Optional: enable detailed logging
DEBUG=typeorm:*The seed script automatically creates these tables (if synchronize: true):
-
users
- id, walletAddress, reputation, createdAt, updatedAt
- Indexes: walletAddress
-
wallets
- id, address, chain, userId, linkedAt
- Indexes: userId, address+chain (unique)
-
claims
- id, resolvedVerdict, confidenceScore, finalized, createdAt
- Indexes: finalized, confidenceScore, resolvedVerdict
-
evidences
- id, claimId, latestVersion, createdAt
- Indexes: claimId
-
evidence_versions
- id, evidenceId, version, cid, createdAt
- Indexes: evidenceId, evidenceId+version
| ID | Wallet Address | Reputation | Role |
|---|---|---|---|
| 1 | 0x1234... | 85 | Experienced verifier |
| 2 | 0xabcd... | 60 | Regular contributor |
| 3 | 0x9876... | 30 | Low-reputation user |
| 4 | 0x1111... | 95 | Expert verifier |
| 5 | 0xaaaa... | 10 | New user |
| ID | Verdict | Confidence | Status | Evidence |
|---|---|---|---|---|
| 1 | TRUE | 95% | Finalized | 2 versions |
| 2 | FALSE | 72% | Finalized | 1 version |
| 3 | NULL | 58% | In Review | 2 pieces |
| 4 | TRUE | 88% | Finalized | 3 versions |
| 5 | NULL | None | New | None |
npm run seed
npm run start:devStart development with pre-populated test data ready for testing API endpoints.
npm run seed -- --clear
npm run testFresh data for each test run ensures isolated test environments.
npm run seed -- --clear
npm run start:prod
# Shows UI with realistic data patternsSeed provides baseline data for testing:
- Claim resolution workflows
- Evidence versioning
- Reputation calculations
- Multi-chain wallet scenarios
Seeded data allows testing all API endpoints:
npm run seed
npm run start:dev
# Visit http://localhost:3000/api (Swagger UI)Error:
Error: SQLITE_CANTOPEN: unable to open database file
Solution:
- Check that the database directory exists
- Ensure write permissions on the directory
- Verify DATABASE_PATH environment variable
Error:
Error: Entity not found in the orm metadata
Solution:
- Verify all entity files exist:
src/entities/user.entity.tssrc/entities/wallet.entity.tssrc/claims/entities/claim.entity.tssrc/claims/entities/evidence.entity.tssrc/claims/entities/evidence-version.entity.ts
Error:
TypeError: Cannot read property 'save' of undefined
Solution:
- Run
npm installto update dependencies - Verify TypeORM is properly installed
- Check Node.js version (requires Node 14+)
Error:
Error: listen EADDRINUSE: address already in use
Solution:
- Kill the process using the port:
npx kill-port 3000 - Or change the port in
.env:PORT=3001
To extend the seed script with additional data:
// Example: Add more users
const user6 = userRepository.create({
walletAddress: '0xNEWADDRESS',
reputation: 75,
});
await userRepository.save(user6);npm run seed -- --clear- ✅ Seed script works reliably - Tested with multiple runs, handles errors gracefully
- ✅ Enables testing/demo - Provides complete sample data for all major entities
- ✅ Covers Users scope - 5 users with varying reputations and multi-chain wallets
- ✅ Covers Claims scope - 5 claims with various resolution states
- ✅ Generates Evidence - Evidence with version history for realistic workflows
# Run the application
npm run start
# Watch mode for development
npm run start:dev
# Run tests
npm run test
# Run e2e tests
npm run test:e2e
# Generate TypeORM migration
npm run migration:generate
# View database (with sqlite3)
sqlite3 database.sqlite- Run --clear before major tests to ensure consistent baseline
- Use in development only unless explicitly testing seed edge cases
- Don't commit database.sqlite to version control
- Update seed data as schema evolves
- Document any manual data needed for specific test scenarios
For issues or enhancements:
- Check the troubleshooting section above
- Review the seed script source:
src/scripts/seed.ts - Check database logs in
database.sqlite - Refer to TypeORM documentation: https://typeorm.io/
Last Updated: March 2026 Seed Data Version: 1.0 Entities Covered: User, Wallet, Claim, Evidence, EvidenceVersion