Ocean Node is the all-in-one backend for the Ocean Protocol stack. A single Node process replaces three legacy components — Provider (data access, encryption, compute), Aquarius (metadata cache) and the subgraph (on-chain event indexing) — and adds Compute-to-Data, payment settlement and more. It exposes an HTTP API and a libp2p peer-to-peer interface, both of which dispatch to one shared set of command handlers.
This README is a quick guide for operators and developers. See the docs/
directory (indexed at the bottom) for the detailed references.
Capabilities
- Metadata indexing — per-chain indexer for DDOs, orders, pricing (fixed-rate / dispenser), access lists and escrow events, with reindexing and purgatory support.
- Provider / consume flows — asset download streaming, encrypt/decrypt, fees, nonce/signature checks and order validation.
- Compute-to-Data (C2D) — Docker-based compute jobs with CPU/RAM/disk/GPU resource matching, free and paid compute, and job result/log retrieval.
- Service-on-Demand — template-driven long-running services (start/stop/restart/extend).
- Escrow / payment settlement — on-chain settlement for paid compute and services.
- Auth tokens — JWT-based auth as an alternative to per-request signatures.
- Persistent storage — local filesystem (
localfs) storage for C2D outputs and user buckets, configured viaPERSISTENT_STORAGE(the S3 backend is a stub). - Policy Server integration — delegate access decisions to an external policy server.
- Pluggable key management — node identity and signer behind a KeyManager abstraction.
- Observability — OpenTelemetry traces/metrics and rotating file logging.
Ocean Node has two front doors and one dispatcher:
- HTTP —
POST /directCommand(plus ergonomic REST routes underprovider,ddo,query,compute,auth,escrow, …) normalizes each request into aCommand. - P2P — a libp2p protocol handler reads length-prefixed command frames off the stream.
Both paths converge on the same CoreHandlersRegistry, where every capability is a command
handler reachable identically over HTTP, over P2P and (for most) via a dedicated REST route.
See Architecture for the layered model and Mermaid diagrams.
- Basic node (indexer + provider + P2P): ~2 vCPU, 4 GB RAM, a few GB of storage for the databases and logs.
- Node running C2D / GPU: C2D runs jobs as Docker containers on the host, so size for the
workloads you intend to accept — multiple cores, substantial RAM/disk, and one or more GPUs
for GPU compute environments. Resource ceilings are declared in
DOCKER_COMPUTE_ENVIRONMENTS. - OS: latest LTS Ubuntu or latest macOS recommended; other OSes (including Windows) should also work.
A persistent databases/ volume is REQUIRED, not optional. It holds
databases/p2p-store, the libp2p datastore that backs this node's DHT provider records, and,
with DB_TYPE=sqlite, all the data of the node. Starting it empty silently drops
content the node still serves. The Dockerfile declares VOLUME ["/usr/src/app/databases"] for this reason —
see "Persistent node data" in Docker deployment.
The recommended way to host a node and be eligible for incentives. Follow the Docker deployment guide. The other options below are aimed at developers who want to tinker.
npm run quickstart
# OR
scripts/ocean-node-quickstart.shThis walks you through setting up the environment variables and deploying the node.
Note
The quickstart script auto-detects GPUs (NVIDIA via nvidia-smi, others via lspci) and
appends them to DOCKER_COMPUTE_ENVIRONMENTS. Detected GPUs are added to
DOCKER_COMPUTE_ENVIRONMENTS[0].resources (the connection-level pool) plus a lightweight
ref in environments[0].resources. If you pre-configure DOCKER_COMPUTE_ENVIRONMENTS
yourself, auto-detected GPUs are merged in, which can duplicate entries — for most
users it is best to let the script handle GPU detection.
PM2 is a process manager that makes it easy to run and monitor Node.js apps.
npm install -g pm2
# 1. Install deps and build — `npm run start` runs dist/index.js, so a prior build is required
npm install
npm run build
# 2. Set up env vars. The node does NOT auto-load .env at runtime (dotenv is only used in
# tests), so the vars must be in the shell environment before `pm2 start`.
# Interactive helper, then load the generated .env into this shell:
npm run setupEnv
source .env
# …or set them manually (only PRIVATE_KEY is mandatory; keep the 0x prefix):
# export PRIVATE_KEY="0x<64-hex-characters>" # or generate one: node dist/helpers/scripts/generatePK.js
# if you use a JSON config file instead, point CONFIG_PATH at its absolute path:
# export CONFIG_PATH="/absolute/path/to/config.json"
# 3. Start under PM2
pm2 start npm --name "ocean-node" -- run startManage it with pm2 list, pm2 logs ocean-node, pm2 restart|stop|delete ocean-node. The
node also writes daily-rotating files to logs/ (see Logs); PM2 keeps its
own stdout copy in ~/.pm2/logs with no size cap unless pm2-logrotate is installed.
Prerequisites
- Node.js: use the version pinned in
.nvmrc(runnvm use). The effective supported runtime is Node 24+ (package.jsonengines), and the.nvmrc/Dockerfile pin the exact tested version (currently 26.12.1). - Docker + Docker Compose (for C2D, and for PostgreSQL or Elasticsearch if you select one of them; SQLite needs no container).
# 1. Install and build
nvm use
npm install
npm run build
# 3. Configure env vars (interactive helper, or set PRIVATE_KEY manually)
./src/helpers/scripts/setupNodeEnv.sh && source .env
# 4. Start
npm run startnpm run start is not a plain node dist/index.js. It runs
node --import ./dist/telemetry/otel.js --max-old-space-size=28784 --trace-warnings --experimental-specifier-resolution=node dist/index.js (identical to the Docker CMD), so a
prior npm run build is required.
PRIVATE_KEY(exactly 66 characters:0x+ 64 hex) andDB_TYPEare the mandatory variables.PRIVATE_KEYseeds the node identity (libp2p peerId), the EVM signer and the encryption keys;DB_TYPEselects the database (sqliteneeds no other setting). Everything else has defaults. Generate a key withnode dist/helpers/scripts/generatePK.js.- Config sources: a JSON config file plus environment-variable overrides. The file is
resolved from
CONFIG_PATH, else./config.jsonin the working directory, and must exist — the repo ships a ready-to-runconfig.json(chain8996/development, a single Docker C2D environment). Environment variables are merged on top of the file and take precedence.⚠️ Blank env vars override the file. Only unset variables fall through toconfig.json; an empty value (e.g.export HTTP_API_PORT=) is treated as set and overrides the file's value.npm run setupEnvcreates.envby copying.env.example, which has many blankexport VAR=lines, so aftersource .envthose blanks shadow yourconfig.json. Remove or comment out the lines you are not actually setting, and keep only the vars you want to override.
INTERFACES(JSON array, e.g.["HTTP","P2P"]) toggles which front doors are enabled; omitted means both.docs/env.mdis the authoritative reference. Key groups worth knowing:RPCS— per-chain RPC endpoint map (JSON).DB_TYPE— the database, required:sqlite,postgresqlorelasticsearch.DB_URL/DB_USERNAME/DB_PASSWORD— the connection, for the last two.ALLOWED_ADMINS,AUTHORIZED_DECRYPTERS,AUTHORIZED_PUBLISHERS,ALLOWED_VALIDATORS(and their access-list variants) — admin / decrypter / validator allow-lists.MAX_REQ_PER_MINUTE,RATE_DENY_LIST— rate limiting.DOCKER_COMPUTE_ENVIRONMENTS— C2D environments, resources and GPUs.POLICY_SERVER_URL— external policy server.JWT_SECRET— signing secret for auth tokens.P2P_*— bind addresses/ports, bootstrap nodes, NAT/relay toggles, announce filtering.
The node keeps all its data in one database, selected with DB_TYPE:
sqlite: no database container and no other setting. The files are in thedatabases/folder. One folder is for one node instance.postgresqlorelasticsearch: for several node instances on one database. SetDB_URL,DB_USERNAMEandDB_PASSWORD(ordbConfiginconfig.json); without them the configuration fails validation and the node does not start. The repo has a compose file for each:postgresql-compose.ymlandelasticsearch-compose.yml.
With no DB_TYPE the node does not start: it does not get the type from DB_URL. See
"Upgrade" in the Database guide.
Version 5.1.0 and older keep the node state (nonces, compute jobs, auth tokens, buckets,
metrics history) in the SQLite files of databases/, and the DDO index in Typesense or
Elasticsearch. A node of this release with DB_TYPE=sqlite keeps all of it in these files.
To move the state of such a node, run this in the folder of its docker-compose.yml:
curl -fsSL https://raw.githubusercontent.com/oceanprotocol/ocean-node/main/scripts/ocean-node-migrate-db.sh | bashThe script:
- Asks for the database:
p(PostgreSQL),e(Elasticsearch) ors(SQLite). The new database takes the place of the old one (Typesense, or Elasticsearch when you select another one; on a SQLite node it is added) indocker-compose.yml(or.yaml), and in thedbConfigofconfig.jsonwhen the compose file mounts it. Withsthe old database goes: the state is in SQLite already, so the node uses the same files and upgrades their tables when it starts. The old files stay in<file>.old; the volume of the old database stays. When the volume of the new database exists already, it asks to remove it. When you keep Elasticsearch, the script protects it: an Elasticsearch withxpack.security.enabled: falsegets security and a new password for the userelastic, and restarts when the node stops. Without that line Elasticsearch 8 has security, so the compose file needsELASTIC_PASSWORD. The node gets the same user and password. The changes that it shows hide the passwords and the private key: they are in the files. When the compose file sets PostgreSQL already (after a quickstart run), the script does not ask and does not change the files: it only copies. Docker compose reads onlydocker-compose.yml(-f). The script stops whenCOMPOSE_FILEorCOMPOSE_ENV_FILESis set, or the folder has acompose.yamlor an override file, because docker compose reads them without-f. - Shows what it will copy and asks you to confirm. The node still runs.
- Stops the node, keeps a copy of the state files in the folder
backup-<time>of the node volume (node-sqlite), and copies the state. A row that is in the target already is written again; a nonce keeps the higher value. - Starts the node. When the copy fails, it puts back the old files and starts the node as before the script. After a good copy the SQLite files move to the backup folder; when the node then does not start, the script shows the error and the command to start it.
The indexed data is not copied: the node indexes the chains again. The script copies only from the SQLite files: a node on PostgreSQL or Elasticsearch does not move to another database. It refuses files of a newer node than its image.
DDO search is the same on all three: a typed query (filters, sort key, page) that each database runs with its own fixed queries. See "DDO search" in the Database guide.
There is no DEGRADED mode: if the database cannot be opened when the node starts (after the
init retries), the node logs Database failed to initialize, exiting and exits with code 1.
A config value of the wrong type instead fails OceanNodeConfigSchema (zod) validation and
stops startup before any DB is initialized. See Database guide, also for
the upgrade from an older release.
Compute-to-Data runs jobs as Docker containers through the host Docker socket. The lifecycle
is initializeCompute → startCompute / freeStartCompute → getComputeStatus →
getComputeResult (+ streamable logs) → stopCompute. Requested CPU/RAM/disk/GPU are matched
against environment resource pools, and paid compute settles through the Escrow component.
Service-on-Demand runs template-driven long-lived services with a similar lifecycle.
- Compute (C2D) configuration — resources, GPUs, constraints, pricing.
- Services (Service-on-Demand).
- Persistent storage for C2D jobs.
-
Build:
npm run build(clean +tsc). Lint/format:npm run lint,npm run lint:fix,npm run format. -
Tests run against compiled JS in
dist/test/, not the TypeScript source. Thetest:*scripts callnpm run build-testsfirst, so re-run it after editing source or tests.npm run test:unit # unit suite npm run test:integration # integration suite (needs Barge) npm run test:computeunit # C2D unit tests (fast) npm run test:computeintegration # C2D integration tests npm run test:servicesintegration # Service-on-Demand integration npm run test:indexer # indexer integration
-
Integration tests require a running local stack — clone
oceanprotocol/bargeand start it with C2D (see testing guide for exact flags per DB backend). -
Adding a command/handler: register the name in
PROTOCOL_COMMANDS+SUPPORTED_PROTOCOL_COMMANDS, add a handler undersrc/components/core/, register it in theCoreHandlersRegistry, add param validation, and optionally wire a REST route. SeeCLAUDE.mdfor the full architecture notes and testing guide.
The node emits OpenTelemetry traces and metrics (loaded via --import ./dist/telemetry/otel.js
at startup) and writes per-module daily-rotating logs to logs/. See
Telemetry and Logging.
Note
npm run logs (the signed /logs API helper) is currently broken — see
docs/Logs.md for the current way to access logs.
Ocean Node builds a libp2p node (TCP + WebSockets, Noise, Yamux, Kademlia DHT + mDNS discovery, circuit-relay v2, AutoNAT, UPnP, auto-TLS) and forwards commands between peers. See Network configuration.
- Architecture
- API reference · Postman collection
- Environment variables
- Database guide
- Asset storage types · Persistent storage
- Compute (C2D) · Services (Service-on-Demand)
- Publishing
- KeyManager · Policy Server
- Telemetry · Logging
- Network configuration
- Testing guide · Docker deployment
CLAUDE.md— in-repo architecture & contributor notes.
- ocean.js (
@oceanprotocol/lib) — JavaScript client library. - ocean-cli — command-line client.
- contracts — Ocean smart contracts.
- barge — Docker-based local full-stack environment for integration testing.