Developer FAQ
Common developer issues, troubleshooting solutions, and debugging tips for the Asset Tokenization Kit
This FAQ addresses common development issues, error messages, and debugging strategies when working with the Asset Tokenization Kit.
Environment setup
Port already in use errors
Q: Docker Compose fails with "port is already allocated" or "address already in use"
A: Another service is using the required port. Common conflicts:
| Service | Default Port | Check Command |
|---|---|---|
| PostgreSQL | 5432 | lsof -i :5432 |
| Redis | 6379 | lsof -i :6379 |
| Besu RPC | 8545 | lsof -i :8545 |
| DApp | 3000 | lsof -i :3000 |
| Hasura | 8080 | lsof -i :8080 |
| MinIO | 9000 | lsof -i :9000 |
Solutions:
-
Stop conflicting service:
# Find process using port lsof -i :5432 # Kill process kill -9 <PID> -
Use different ports (edit
docker-compose.yml):services: postgresql: ports: - "5433:5432" # Host:ContainerUpdate connection strings in
.env.local:DATABASE_URL="postgresql://postgres:atk@localhost:5433/postgres" -
Reset Docker networking:
docker network prune docker-compose down --volumes docker-compose up -d
Bun installation fails
Q: bun install fails with "permission denied" or "EACCES"
A: Node modules or cache directories have incorrect permissions.
Solutions:
-
Clear Bun cache:
rm -rf ~/.bun bun install -
Reset node_modules ownership:
sudo chown -R $(whoami) node_modules -
Use correct Bun version (check
.bun-versionfile):bun --version # Should match version in .bun-version # Install specific version curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.1"
Docker out of memory
Q: Docker services crash or become unresponsive
A: Docker Desktop memory limit is too low for the full stack.
Solutions:
-
Increase Docker memory (Docker Desktop → Settings → Resources):
- Minimum: 8GB RAM
- Recommended: 16GB RAM
-
Check current limits:
docker info | grep -i memory -
Reduce services (disable unused components in
docker-compose.yml):# Comment out optional services # ipfs: # ... # blockscout: # ... -
Monitor resource usage:
docker stats
Database connection refused
Q: DApp fails with "connection refused" or "could not connect to server"
A: PostgreSQL isn't ready or environment variables are incorrect.
Solutions:
-
Wait for PostgreSQL startup:
docker-compose logs postgresql # Look for: "database system is ready to accept connections" -
Verify connection string (
.env.local):# Check format DATABASE_URL="postgresql://postgres:atk@localhost:5432/postgres?sslmode=disable" -
Test connection manually:
psql -h localhost -U postgres -d postgres # Password: atk (default) -
Recreate database:
docker-compose down -v docker-compose up -d postgresql # Wait 10 seconds bun run --cwd kit/dapp db:migrate
Smart contracts
Genesis file issues
Q: Besu node fails to start with "genesis block mismatch" or "invalid genesis"
A: Genesis file is outdated or corrupted after contract changes.
Solutions:
-
Regenerate genesis allocations:
bun run artifactsThis runs:
compile:forge(compile contracts)codegen:types(generate TypeScript bindings)artifacts:genesis(create genesis allocations)artifacts:abi(export ABIs)
-
Reset blockchain state:
bun run dev:resetThis deletes volumes and recreates the environment with fresh genesis.
-
Verify genesis file exists:
ls -lh kit/contracts/.generated/genesis.json ls -lh kit/contracts/.generated/genesis-allocations.json -
Check contract addresses in genesis match subgraph config:
# SystemFactory should be at predefined address rg "0x5e771e1417100000000000000000000000020088" kit/subgraph/subgraph.yaml
Contract compilation errors
Q: forge build or hardhat compile fails with Solidity errors
A: Syntax errors, version mismatches, or missing dependencies.
Solutions:
-
Check Solidity version (contracts use
^0.8.28):forge --version # Should show solc 0.8.28 or compatible -
Update Foundry:
foundryup -
Clean build cache:
cd kit/contracts forge clean forge build -
Check for syntax errors:
bun run lintFix issues reported by Solhint.
-
Verify dependencies (Foundry uses
soldeer.lock):forge soldeer update
ABI generation fails
Q: TypeScript types are missing or outdated after contract changes
A: Code generation step hasn't run or failed silently.
Solutions:
-
Regenerate types:
cd kit/contracts bun run codegen:types -
Check ABIs exist:
ls kit/contracts/.generated/portal/ # Should contain .json files for each contract -
Verify import paths in DApp:
import { bondTokenAbi } from "@/contracts/abis/BondToken"; // Path should resolve to generated ABI -
Rebuild DApp after regenerating types:
cd kit/dapp bun run build
Test failures after contract changes
Q: Foundry tests fail with "call reverted" or "assertion failed"
A: Contract behavior changed without updating tests.
Solutions:
-
Run tests with verbose output:
forge test -vvvvShows:
- Function calls
- Revert reasons
- Gas usage
-
Check specific test:
forge test --match-test test_TransferBond -vvvv -
Update test expectations:
// Old expectation vm.expectRevert("Transfer not allowed"); // New error message after contract change vm.expectRevert("Compliance check failed"); -
Reset test state (if using fork mode):
forge clean forge test
Subgraph
Subgraph deployment fails
Q: graph deploy fails with "failed to deploy" or "schema validation error"
A: Schema doesn't match entity definitions or addresses are incorrect.
Solutions:
-
Verify contract addresses in
subgraph.yaml:cd kit/subgraph rg "address:" subgraph.yamlAddresses must match genesis allocations.
-
Regenerate subgraph config:
bun run codegen -
Check schema syntax:
graph build # Look for validation errors -
Reset Graph Node:
docker-compose restart graph-node -
Deploy with correct network:
graph deploy --node http://localhost:8020 --ipfs http://localhost:5001 atk
Subgraph not indexing
Q: Subgraph deployed but queries return empty results
A: Indexing hasn't started or Graph Node can't reach Besu.
Solutions:
-
Check indexing status:
curl -X POST http://localhost:8030/graphql \ -H "Content-Type: application/json" \ -d '{"query": "{ indexingStatuses { subgraph health } }"}' -
View Graph Node logs:
docker-compose logs graph-node | tail -100Look for:
- Connection errors to Besu
- Block processing progress
- Entity updates
-
Verify Besu RPC is accessible:
curl -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -
Trigger events to index:
# Create a test bond to generate events cd kit/dapp # Use UI or API to create asset -
Redeploy subgraph:
cd kit/subgraph bun run deploy:local
AssemblyScript test failures
Q: graph test fails with compilation errors
A: Test syntax doesn't match AssemblyScript requirements.
Solutions:
-
Use correct assertion methods:
import { assert } from "matchstick-as"; // Correct assert.stringEquals(bond.name, "Corporate Bond"); // Wrong (JavaScript syntax) expect(bond.name).toBe("Corporate Bond"); -
Handle nullable types explicitly:
// AssemblyScript requires null checks let bond = BondToken.load(bondId); if (bond != null) { assert.bigIntEquals(bond.faceValue, BigInt.fromI32(1000)); } -
Clear test data between runs:
import { clearStore } from "matchstick-as"; export function afterEach(): void { clearStore(); }
DApp and frontend
Hot reload not working
Q: Changes to code don't reflect in browser
A: Vite dev server isn't detecting file changes or cache is stale.
Solutions:
-
Restart dev server:
# Stop (Ctrl+C) bun run dev -
Clear Vite cache:
rm -rf kit/dapp/.vite bun run dev -
Check file watcher limits (Linux):
# Increase inotify limits echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf sudo sysctl -p -
Hard refresh browser:
- Chrome/Edge: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)
- Firefox: Ctrl+F5 (Windows/Linux) or Cmd+Shift+R (Mac)
GraphQL query errors
Q: Queries fail with "Cannot query field" or "Unknown type"
A: Hasura metadata is out of sync or permissions are incorrect.
Solutions:
-
Reload Hasura metadata:
curl -X POST http://localhost:8080/v1/metadata \ -H "x-hasura-admin-secret: atk" \ -H "Content-Type: application/json" \ -d '{"type": "reload_metadata", "args": {}}' -
Track tables manually (Hasura Console at
http://localhost:8080/console):- Go to "Data" tab
- Select "public" schema
- Click "Track All" tables
-
Regenerate Hasura metadata:
cd kit/dapp bun run db:migrate # Restart Hasura docker-compose restart hasura -
Check permissions:
- Open Hasura Console
- Go to table → Permissions
- Ensure "user" role has select/insert/update permissions
Authentication issues
Q: Login fails or redirects to error page
A: Better Auth configuration is incorrect or session storage failed.
Solutions:
-
Verify
BETTER_AUTH_URLin.env.local:BETTER_AUTH_URL="http://localhost:3000" # Must match actual host and port -
Check database connection:
Better Auth stores sessions in PostgreSQL. Verify tables exist:
psql -h localhost -U postgres -d postgres -c "\dt auth.*"Should show:
auth.userauth.sessionauth.account
-
Clear cookies and storage:
- Open browser DevTools (F12)
- Application → Clear site data
- Refresh and try login again
-
Check auth logs:
# DApp server logs docker-compose logs dapp | grep -i auth
Build errors with Vite
Q: bun run build fails with module resolution errors
A: Import paths are incorrect or dependencies are missing.
Solutions:
-
Verify path aliases (
tsconfig.json):{ "compilerOptions": { "paths": { "@/*": ["./src/*"], "@schemas/*": ["./src/lib/schemas/*"] } } } -
Check for circular dependencies:
bunx madge --circular kit/dapp/src -
Clear build cache:
rm -rf kit/dapp/dist kit/dapp/.vite bun run build -
Reinstall dependencies:
rm -rf node_modules bun install
Testing
E2E tests timing out
Q: Playwright tests fail with "Timeout 30000ms exceeded"
A: Application is slow to respond or selectors are incorrect.
Solutions:
-
Increase timeout in
playwright.config.ts:export default defineConfig({ timeout: 60000, // 60 seconds }); -
Wait for specific conditions:
// Instead of waitForTimeout await page.waitForURL("/bonds/123"); await page.waitForSelector('[data-testid="bond-details"]'); -
Check backend services are running:
docker-compose ps # All services should be "Up" -
Run tests headed to debug:
bun run test:ui:headed -
Disable animations:
test.use({ hasTouch: false, reducedMotion: "reduce", });
Vitest tests fail with import errors
Q: Unit tests fail with "Cannot find module" or "Unexpected token"
A: Module resolution or transformation is broken.
Solutions:
-
Check
vitest.config.tsresolve settings:export default defineConfig({ resolve: { alias: { "@": "/src", }, }, }); -
Clear Vitest cache:
rm -rf kit/dapp/node_modules/.vitest bun run test:unit -
Mock problematic imports:
// In test file vi.mock("some-esm-only-package", () => ({ default: vi.fn(), }));
Forge tests fail with stack too deep
Q: Contract tests fail with "CompilerError: Stack too deep"
A: Function has too many local variables or complex logic.
Solutions:
-
Enable via-IR compilation (
foundry.toml):[profile.default] via-ir = true optimizer = true optimizer-runs = 200 -
Refactor test function:
// Instead of many variables function test_Transfer() public { uint256 amount = 100; uint256 fee = 10; uint256 balance = 1000; // ...many more variables // Extract to helper function test_Transfer() public { TransferParams memory params = _setupTransfer(); _executeTransfer(params); } -
Use structs for parameters:
struct TestParams { uint256 amount; uint256 fee; address sender; }
Performance
Slow DApp load times
Q: Application takes >10 seconds to load
A: Bundle size is too large or database queries are unoptimized.
Solutions:
-
Analyze bundle size:
cd kit/dapp bun run build # Check output for large chunks -
Lazy load routes:
// In router config const Route = createFileRoute("/bonds/$bondId")({ component: lazy(() => import("./components/BondDetails")), }); -
Check database indexes:
-- Connect to PostgreSQL psql -h localhost -U postgres -d postgres -- Check slow queries SELECT query, mean_exec_time FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10; -- Add indexes for common queries CREATE INDEX idx_bonds_issuer ON bonds(issuer_id); -
Enable response caching (Redis):
Verify Hasura caching is enabled in
docker-compose.yml.
High memory usage
Q: Node process uses >4GB RAM during development
A: Memory leak or too many watchers.
Solutions:
-
Restart dev server periodically:
# Stop dev server # Clear node modules cache rm -rf node_modules/.cache bun run dev -
Reduce Turbo concurrency:
# In package.json scripts "dev": "turbo run dev --concurrency=5" -
Check for memory leaks with Chrome DevTools:
- Open Performance tab
- Record heap snapshots during interaction
- Look for detached DOM nodes or growing arrays
CI/CD
GitHub Actions workflow fails
Q: CI pipeline fails at specific step
A: Environment differences or flaky tests.
Solutions:
-
Check workflow logs:
- Open GitHub Actions tab
- Click failed workflow run
- Expand failed step to view logs
-
Reproduce locally:
# Run full CI suite bun run ci -
Common failure points:
Step Common Cause Fix bun installLock file out of sync bun install && git add bun.locktest:ciFlaky E2E tests Increase timeouts, add retries buildType errors Fix TypeScript errors locally chart-testingResource limits Check Kubernetes namespace quotas -
Skip tests for draft PRs:
GitHub Actions skips expensive tests for draft PRs. Convert to ready for review when tests should run.
Docker build fails in CI
Q: docker build succeeds locally but fails in GitHub Actions
A: Platform differences (arm64 vs amd64) or build cache issues.
Solutions:
-
Build for correct platform (GitHub Actions uses amd64):
# In Dockerfile FROM --platform=linux/amd64 oven/bun:1.3.1-alpine -
Clear build cache:
docker builder prune -af -
Use BuildKit:
# In GitHub Actions workflow env: DOCKER_BUILDKIT: 1 -
Check for large layers:
docker history ghcr.io/settlemint/asset-tokenization-kit:latest
Debugging tips
Enable debug logging
Add environment variables to .env.local:
# DApp server logs
DEBUG=*
# Vite dev server
VITE_DEBUG=true
# Drizzle ORM queries
DATABASE_DEBUG=trueInspect Docker container
# Enter running container
docker-compose exec dapp sh
# View container logs
docker-compose logs -f dapp
# Check container resource usage
docker statsDatabase queries
# Connect to PostgreSQL
docker-compose exec postgresql psql -U postgres
# List tables
\dt
# View table schema
\d bonds
# Run query
SELECT * FROM bonds LIMIT 10;Network debugging
# Check service connectivity
docker-compose exec dapp curl http://hasura:8080/healthz
# View Docker network
docker network inspect asset-tokenization-kit_defaultGetting help
If issues persist:
- Search existing issues: GitHub Issues
- Check documentation: Developer Guides
- Ask in discussions: GitHub Discussions
- Report a bug: New Issue
Include when reporting:
- Error message (full stack trace)
- Steps to reproduce
- Environment (OS, Node/Bun version, Docker version)
- Relevant logs (sanitize secrets)
Next steps
- Review Development Environment for setup details
- See Testing and QA for debugging test failures
- Explore Deployment Guide for production issues
- Consult Code Structure for architecture understanding