Nillion is a secure computation network that decentralizes trust for high-value, sensitive, and private data in the same way that blockchains decentralize transactions. Learn more about nillion and nilDB in our docs.
- Node.js ≥ 23.0
- pnpm
- Docker
-
Clone the repository:
git clone git@github.com:NillionNetwork/nil-db.git cd nil-db
-
Install dependencies and set up environment:
pnpm install pnpm install-hooks cp .env.example .env
-
If desired, configure your .env file with appropriate values.
-
Start MonogDB:
docker run -d -p 27017:27017 mongo:8
-
Start the API:
pnpm dev # or start for non-watch mode
Run the test suite:
pnpm test
Note:
- Tests use a dedicated test database
- The test database is dropped at the start of each test run
- Test database state is preserved after runs for inspection
This section provides a high level flow to help orientate yourself as a nilDB admin.
-
Root credentials are set by the env var
APP_ROOT_USER_SECRET_KEY
. -
After starting your node you can access its public key with:
curl ${NODE_URL}/about { "started": "2025-01-14T12:10:30.707Z", "build": { "time": "1970-01-01T00:00:00Z", "commit": "unknown", "version": "0.0.0" }, "did": "did:nil:testnet:nillion1eunreuzltxglx9fx493l2r8ef6rdlrau4dsdnc", "publicKey": "02d1f198df9a64ffa27c293861bace8c80bd6b1e150e008267f7f94eae9e6c380c", "url": "http://localhost:8080" }
-
Now, create a root jwt using the nodes public key and your root secret key:
tsc bin/credentials.ts --secret-key ${APP_ROOT_USER_SECRET_KEY} --node-public-key ${APP_NODE_PUBLIC_KEY}
-
Generate admin credentials:
tsx bin/credentials.ts
-
Use the root jwt to create the admin account:
curl ${NODE_URL}/api/v1/admin/accounts \ --header "authorization: bearer ${ROOT_JWT}" \ --header "content-type: application/json" \ -d '{ "did": "${ADMIN_DID}", "publicKey": "${ADMIN_PK}" }'
-
Once the account is created generate a JWT for your admin and the target node:
tsx bin/credentials.ts --secret-key ${ADMIN_USER_SECRET_KEY} --node-public-key ${APP_NODE_PUBLIC_KEY}
When the node is running a swagger ui is available at /api/v1/openapi/docs/
. The UI is based on this openapi specification.
Note: Admin routes are not documented.
- Open an issue to discuss proposed changes
- Submit a pull request with your changes
- Ensure all tests pass and documentation is updated