Local Development Setup

View as Markdown

Set up a local development environment for IDA with all services running natively.

Prerequisites

ToolVersionInstallation
Go1.22+brew install go
Rust1.76+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Node.js20 LTSbrew install node@20
PostgreSQL16+brew install postgresql@16
Redis7+brew install redis
NATS2.10+brew install nats-server
Solidity0.8.24+Via foundry: curl -L https://foundry.paradigm.xyz | bash
IPFS0.27+brew install ipfs

Repository Structure

ida/
packages/
api/ # Go/Rust backend services
cmd/ # Service entrypoints
internal/ # Internal packages
pkg/ # Public libraries
blockchain/ # Smart contracts
contracts/ # Solidity source
scripts/ # Deployment scripts
test/ # Contract tests
portal/ # React web portal
src/
wallet/ # Mobile wallet
deployments/ # Docker, K8s manifests
docs/ # This documentation

1. Clone and Install Dependencies

$git clone https://github.com/infinia/ida.git
$cd ida
$
$# Install all workspace dependencies
$make install

The make install command runs:

1install:
2 cd packages/api && go mod download
3 cd packages/blockchain && forge install
4 cd packages/portal && npm install

2. Start Infrastructure Services

Start PostgreSQL, Redis, and NATS locally:

$# Start PostgreSQL
$brew services start postgresql@16
$createdb ida_dev
$
$# Start Redis
$brew services start redis
$
$# Start NATS
$nats-server -D &
$
$# Start IPFS daemon
$ipfs init # first time only
$ipfs daemon &

3. Start ADI Local Devnet

Run a 2-node ADI blockchain for local development:

$cd packages/blockchain
$make devnet

This starts two ADI nodes on ports 30303 and 30304 with pre-funded accounts for testing.

4. Deploy Smart Contracts

Deploy the four core smart contracts to the local devnet:

$cd packages/blockchain
$forge script scripts/Deploy.s.sol --rpc-url http://localhost:30303 --broadcast

Output:

Deploying DID Registry... deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3
Deploying Schema Registry... deployed at 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Deploying Revocation Registry... deployed at 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
Deploying Agent Trust Registry... deployed at 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9

Record these addresses in your .env file.

5. Configure Environment

Create a .env file in the project root:

$cp .env.example .env
1# Database
2DATABASE_URL=postgres://localhost:5432/ida_dev?sslmode=disable
3REDIS_URL=redis://localhost:6379
4
5# ADI Blockchain
6ADI_RPC_URL=http://localhost:30303
7ADI_CHAIN_ID=1337
8
9# Smart Contract Addresses
10DID_REGISTRY_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
11SCHEMA_REGISTRY_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
12REVOCATION_REGISTRY_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
13AGENT_TRUST_REGISTRY_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
14
15# NATS
16NATS_URL=nats://localhost:4222
17
18# IPFS
19IPFS_API_URL=http://localhost:5001
20
21# API
22API_PORT=8080
23RESOLVER_PORT=8081
24LOG_LEVEL=debug

6. Run Database Migrations

$cd packages/api
$make migrate-up

7. Start the API Server

$cd packages/api
$make run

The API will be available at http://localhost:8080.

8. Start the Web Portal

$cd packages/portal
$npm run dev

The portal will be available at http://localhost:5173.

9. Run Tests

$# Smart contract tests
$cd packages/blockchain && forge test -vvv
$
$# API unit tests
$cd packages/api && go test ./...
$
$# API integration tests (requires running services)
$cd packages/api && go test -tags=integration ./...
$
$# Portal tests
$cd packages/portal && npm test

10. Useful Make Commands

CommandDescription
make installInstall all dependencies
make devStart all services in dev mode
make testRun all tests
make lintRun linters across all packages
make buildBuild all packages
make docker-buildBuild Docker images
make migrate-upRun database migrations
make migrate-downRollback database migrations
make deploy-contractsDeploy smart contracts to devnet
make cleanClean build artifacts

IDE Setup

VS Code Extensions

  • Go (golang.go)
  • rust-analyzer
  • ESLint
  • Tailwind CSS IntelliSense
  • Solidity (JuanBlanco.solidity)
  • Prettier
1{
2 "editor.formatOnSave": true,
3 "go.lintTool": "golangci-lint",
4 "rust-analyzer.cargo.allTargets": true,
5 "tailwindCSS.experimental.classRegex": [
6 ["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
7 ]
8}

Troubleshooting

IssueSolution
Port 8080 in uselsof -i :8080 and kill the process
Database connection failedVerify PostgreSQL is running: pg_isready
Contract deployment failsEnsure ADI devnet is running: curl http://localhost:30303
IPFS connection refusedStart the daemon: ipfs daemon &
Redis connection refusedStart Redis: brew services start redis