CLI tool to interact with the oceanprotocol's JavaScript library to privately & securely publish, consume and run compute on data.
With the Ocean CLI tool you can:
- Publish data services: downloadable files or compute-to-data.
- Edit existing assets.
- Consume data services, ordering datatokens and downloading data.
- Compute to data on public available datasets using a published algorithm.
- Manage access control with access lists for restricting dataset/algorithm access.
- Handle escrow payments for compute jobs with deposit, withdrawal, and authorization.
- Manage authentication with token generation and invalidation.
Ocean CLI is using ocean.js JavaScript library which is part of the Ocean Protocol toolset.
If you run into problems, please open up a new issue.
- node.js (Install from here)
- A Unix based operating system (Mac or Linux)
$ git clone https://github.com/oceanprotocol/ocean-cli.git
npm install- Set a private key(by exporting env "PRIVATE_KEY") or a mnemonic (by exporting env "MNEMONIC")
export PRIVATE_KEY="XXXX"
or
export MNEMONIC="XXXX"
- Set an RPC
export RPC='XXXX'
- Mandatory, Set an Ocean Node URL. Ocean Nodes infrastructure is responsible for handling assets indexing and metadata caching. It replaced old Provider and Aquarius standalone apps.
export NODE_URL='XXXX'
- Optional, set ADDRESS_FILE if you want to use a custom set of smart contract address
export ADDRESS_FILE='path-to-address-file'
- Optional, set INDEXING_MAX_RETRIES to the max number of retries when waiting for an asset to be indexed. Default is 100 retries max.
export INDEXING_MAX_RETRIES='100'
- Optional, set INDEXING_RETRY_INTERVAL to the interval (in miliseconds) for each retry when waiting for an asset to be indexed. Default is 3 seconds.
export INDEXING_RETRY_INTERVAL='3000'
- Optional, set AVOID_LOOP_RUN to 'true' to run each command and exit afterwards (usefull for CI test env and default behaviour). IF not set or set to 'false' the CLI will listen interactively for commands, until exit is manually forced
export AVOID_LOOP_RUN='true/false'
- Optional, set SSI_WALLET_API, SSI_WALLET_ID, SSI_WALLET_DID to support v5 DDOs (assets using credentialSubject and SSI policy flows).
export SSI_WALLET_API="https://your-ssi-wallet.example/api"
export SSI_WALLET_ID="did:example:your-wallet-did-or-id"
export SSI_WALLET_DID="did:example"npm run build
List available commands
npm run cli h
E.g. run publish command
Make sure to update chainId and serviceEndpoint from the assets from metadata folder.
npm run cli publish metadata/simpleDownloadDataset.json
The Ocean CLI supports flexible argument ordering. You can supply arguments using:
- Positional Arguments (traditional style): Must follow the defined order.
- Named Options: Can be provided in any order. These options include flags like
--did,--file, etc.
npm run cli <command> [options] <arguments>-
General help:
npm run cli --helpornpm run cli -h -
Command-specific help:
npm run cli help <command>
Get DDO:
-
Positional:
npm run cli getDDO did:op:123 -
Named Option:
npm run cli getDDO --did did:op:123
Publish:
-
Positional:
npm run cli publish metadata.json -
Named Options:
npm run cli publish --file metadata.json
With encryption disabled:
npm run cli publish --file metadata.json --encrypt false
(Note:--fileand--encryptcan be in any order.)
Publish Algorithm:
-
Positional:
npm run cli publishAlgo algorithm.json -
Named Options:
npm run cli publishAlgo --file algorithm.json
With encryption disabled:
npm run cli publishAlgo --encrypt false --file algorithm.json
Edit Asset:
-
Positional:
npm run cli editAsset did:op:123 metadata.json -
Named Options:
npm run cli editAsset --did did:op:123 --file metadata.json
(The flags can be provided in any order, for example:
npm run cli editAsset --file metadata.json --did did:op:123)
Download:
-
Positional:
npm run cli download did:op:123 ./custom-folder serviceId -
Named Options:
npm run cli download --did did:op:123 --folder ./custom-folder --service serviceId(Order of--didand--folderdoes not matter.) -
Rules: serviceId is optional. If omitted, the CLI defaults to the first available download service.
Start Compute:
-
Positional:
npm run cli startCompute -- did1,did2 algoDid env1 maxJobDuration paymentToken resources svc1,svc2 algoServiceId -
Named Options:
npm run cli startCompute --datasets did1,did2 --algo algoDid --env env1 --maxJobDuration maxJobDuration --token paymentToken --resources resources --accept true --services svc1,svc2 --algo-service algoServiceId(Options can be provided in any order.) -
Rules: serviceIds and algoServiceId are optional. If omitted, the CLI defaults to the first available service.
-
maxJobDurationis a required parameter an represents the time measured in seconds for job maximum execution, the payment is based on this maxJobDuration value, user needs to provide this. -
paymentTokenis required and represents the address of the token that is supported by the environment for processing the compute job payment. It can be retrieved fromgetComputeEnvironmentscommand output. -
resourcesis required and represents a stringified JSON object obtained fromgetComputeEnvironmentscommand output.getComputeEnvironmentscommand shows the available resources and the selected resources by the user need to be within the available limits. e.g.:'[{"id":"cpu","amount":3},{"id":"ram","amount":16772672536},{"id":"disk","amount":0}]' -
--acceptoption can be set totrueorfalse. If it is set tofalsea prompt will be displayed to the user for manual accepting the payment before starting a compute job. If it is set totrue, the compute job starts automatically, without user input. -
outputis an optional stringified JSON object specifying a remote storage backend where job results will be uploaded. Supported types include S3, FTP, URL, Arweave, and IPFS. If omitted, results are stored on the node's local disk. e.g.:'{"remoteStorage":{"type":"s3","s3Access":{"endpoint":"https://s3.amazonaws.com","region":"us-east-1","bucket":"my-results","objectKey":"jobs/result.tar","accessKeyId":"AKIA...","secretAccessKey":"..."}}}'
Raw (unpublished) datasets and algorithms:
Instead of a DID, you can pass a full ComputeAsset (datasets) or ComputeAlgorithm (algorithm) JSON object with a fileObject, to run compute on raw data/algorithms that are not published as assets. Raw entries have no DID and are not ordered (no datatoken). DID-based and raw entries can be mixed within the datasets argument (the value must then be valid JSON, with DIDs quoted). JSON must be single-quoted on the shell.
- Raw algorithm against a published dataset that allows raw algorithms (
allowRawAlgorithm: true):
npm run cli startCompute -- did:op:dataset '{"fileObject":{"type":"url","url":"https://example.com/algo.py","method":"GET"},"meta":{"container":{"entrypoint":"python $ALGO","image":"oceanprotocol/algo_dockers","tag":"python-branin","checksum":"sha256:..."}}}' env1 900 paymentToken resources --accept true - Raw dataset(s) against a published algorithm:
npm run cli startCompute -- '[{"fileObject":{"type":"url","url":"https://example.com/data.csv","method":"GET"}}]' did:op:algo env1 900 paymentToken resources --accept true - Mixed datasets (a published DID and a raw file):
npm run cli startCompute -- '["did:op:dataset",{"fileObject":{"type":"ipfs","hash":"Qm..."}}]' did:op:algo env1 900 paymentToken resources --accept true
Start Free Compute:
-
Positional:
npm run cli startFreeCompute did1,did2 algoDid env1 -
Named Options:
npm run cli startFreeCompute --datasets did1,did2 --algo algoDid --env env1 --services svc1,svc2 --algo-service algoServiceId(Options can be provided in any order.)outputis an optional stringified JSON object specifying a remote storage backend where job results will be uploaded. Same format asstartCompute.
-
Rules: serviceIds and algoServiceId are optional. If omitted, the CLI defaults to the first available service.` (Options can be provided in any order.)
-
outputis an optional stringified JSON object specifying a remote storage backend where job results will be uploaded. Same format asstartCompute. -
Like
startCompute, the datasets and algorithm arguments accept rawComputeAsset/ComputeAlgorithmJSON objects with afileObject(no DID), and mixed DID + raw datasets. e.g.:
npm run cli startFreeCompute did:op:dataset '{"fileObject":{"type":"url","url":"https://example.com/algo.py","method":"GET"},"meta":{"container":{"entrypoint":"python $ALGO","image":"oceanprotocol/algo_dockers","tag":"python-branin","checksum":"sha256:..."}}}' env1
Stop Compute:
-
Positional:
npm run cli stopCompute did:op:123 job-123 -
Named Options:
npm run cli stopCompute --dataset did:op:123 --job job-123
(Optionally, you can also provide an agreement ID using--agreement.)
Get Compute Environments:
npm run cli getComputeEnvironments
Optionally pass a specific Ocean Node URL or peer id to query instead of NODE_URL:
npm run cli getComputeEnvironments <nodeUrlOrPeerId>
Get Compute Streamable Logs:
npm run cli computeStreamableLogs
Get Job Status:
-
Positional:
npm run cli getJobStatus did:op:123 job-123 -
Named Options:
npm run cli getJobStatus --dataset did:op:123 --job job-123
(Optionally, an agreement ID may be provided.)
Download Job Results:
-
Positional:
npm run cli downloadJobResults job-123 0 ./results -
Named Options:
npm run cli downloadJobResults --job job-123 --index 0 --folder ./results
Mint Ocean:
- Positional:
npm run cli mintOcean
(No arguments are required for this command.)
Generate Auth Token:
npm run cli generateAuthToken
(No arguments are required for this command.)
Invalidate Auth Token:
-
Positional:
npm run cli invalidateAuthToken myAuthToken123 -
Named Option:
npm run cli invalidateAuthToken --token myAuthToken123
Deposit to Escrow:
-
Positional:
npm run cli depositEscrow 0x1234...tokenAddress 100 -
Named Options:
npm run cli depositEscrow --token 0x1234...tokenAddress --amount 100
Get User Funds in Escrow:
-
Positional:
npm run cli getUserFundsEscrow 0x1234...tokenAddress -
Named Option:
npm run cli getUserFundsEscrow --token 0x1234...tokenAddress
Withdraw from Escrow:
-
Positional:
npm run cli withdrawFromEscrow 0x1234...tokenAddress 50 -
Named Options:
npm run cli withdrawFromEscrow --token 0x1234...tokenAddress --amount 50
Authorize Escrow Payee:
-
Positional:
npm run cli authorizeEscrow 0x1234...tokenAddress 0x5678...payeeAddress 1000 3600 10 -
Named Options:
npm run cli authorizeEscrow --token 0x1234...tokenAddress --payee 0x5678...payeeAddress --maxLockedAmount 1000 --maxLockSeconds 3600 --maxLockCounts 10 -
Arguments:
token: Address of the token to authorizepayee: Address of the payee to authorizemaxLockedAmount: Maximum amount that can be locked by payeemaxLockSeconds: Maximum lock duration in secondsmaxLockCounts: Maximum number of locks allowed
Get Escrow Authorizations:
-
Positional:
npm run cli getAuthorizationsEscrow 0x1234...tokenAddress 0x5678...payeeAddress -
Named Options:
npm run cli getAuthorizationsEscrow --token 0x1234...tokenAddress --payee 0x5678...payeeAddress
Create Access List:
-
Positional:
npm run cli createAccessList "My Access List" "MAL" "0xUser1,0xUser2" false -
Named Options:
npm run cli createAccessList --name "My Access List" --symbol "MAL" --initial-users "0xUser1,0xUser2" --transferable false -
Arguments:
name: Name for the access listsymbol: Symbol for the access listinitialUsers: Comma-separated list of initial user addresses (optional)transferable: Whether tokens are transferable (true/false, optional, default:false)
Add to Access List:
-
Positional:
npm run cli addToAccessList 0x1234...accessListAddress "0xUser1,0xUser2" -
Named Options:
npm run cli addToAccessList --address 0x1234...accessListAddress --users "0xUser1,0xUser2"
Check Access List:
-
Positional:
npm run cli checkAccessList 0x1234...accessListAddress "0xUser1,0xUser2" -
Named Options:
npm run cli checkAccessList --address 0x1234...accessListAddress --users "0xUser1,0xUser2"
Remove from Access List:
-
Positional:
npm run cli removeFromAccessList 0x1234...accessListAddress "0xUser1,0xUser2" -
Named Options:
npm run cli removeFromAccessList --address 0x1234...accessListAddress --users "0xUser1,0xUser2"
Allow Algorithm on Dataset:
-
Positional:
npm run cli allowAlgo did:op:dataset did:op:algo -
With named option:
npm run cli allowAlgo did:op:dataset did:op:algo --encrypt true -
The dataset and algorithm DIDs are required positional arguments (
--dataset/--algomay override them, but the positionals must still be supplied).--encrypttoggles DDO encryption (default:true). -
Approves an algorithm to run on a compute-enabled dataset (signer must be the dataset NFT owner).
Create Bucket:
npm run cli createBucket
-
Creates a new persistent-storage bucket on the node. Pass an access-list contract address to gate it; omit for owner-only access:
npm run cli createBucket 0x1234...accessListAddress
Add File to Bucket:
npm run cli addFileToBucket <bucketId> ./path/to/file.csv
-
Optionally pass a name to store the file under (defaults to the file's basename):
npm run cli addFileToBucket <bucketId> ./path/to/file.csv results.csv
List Buckets:
npm run cli listBuckets
-
Lists buckets owned by the signer, or by a specific owner:
npm run cli listBuckets --owner 0x1234...ownerAddress
List Files in Bucket:
npm run cli listFilesInBucket <bucketId>
Get File Object:
npm run cli getFileObject <bucketId> <fileName>
- Returns the file-object descriptor for a file in a bucket.
Delete File:
npm run cli deleteFile <bucketId> <fileName>
Download Node Logs (admin):
-
Positional:
npm run cli downloadNodeLogs ./logs 24 -
Named Options:
npm run cli downloadNodeLogs --output ./logs --last 24 -
Downloads node logs into
<output>/logs.json. Use eitherlast(hours from now) or afrom/toepoch-ms range.maxLogscaps the number of entries (default: 100, max: 1000). Requires admin privileges on the node.
-
getDDO:
-d, --did <did> -
publish:
-f, --file <metadataFile>
-e, --encrypt [boolean](Default:true) -
publishAlgo:
-f, --file <metadataFile>
-e, --encrypt [boolean](Default:true) -
editAsset:
-d, --did <datasetDid>
-f, --file <metadataFile>
-e, --encrypt [boolean](Default:true) -
download:
-d, --did <did>
-f, --folder [destinationFolder](Default:.)-s, --service <serviceId>(Optional, target a specific service) -
allowAlgo:
-d, --dataset <datasetDid>
-a, --algo <algoDid>
-e, --encrypt [boolean](Default:true) -
startCompute:
-d, --datasets <datasetDids>-a, --algo <algoDid>-e, --env <computeEnvId>--init <initializeResponse>--maxJobDuration <maxJobDuration>-t, --token <paymentToken>--resources <resources>--amountToDeposit <amountToDeposit>(Id'', it will fallback to initialize compute payment amount.)-o, --output [output](Optional. Stringified JSON object specifying a remote storage backend for job results.)-s, --services [serviceIds](Optional, comma-separated; must match datasetDids length, positional 1β1)-x, --algo-service [algoServiceId](Optional, override algorithm service) -
startFreeCompute:
-d, --datasets <datasetDids>
-a, --algo <algoDid>
-e, --env <computeEnvId>-o, --output [output](Optional. Stringified JSON object specifying a remote storage backend for job results.)-s, --services [serviceIds](Optional, comma-separated; must match datasetDids length, positional 1β1)-x, --algo-service [algoServiceId](Optional, override algorithm service) -
getComputeEnvironments:
-n, --node [node](Optional. Ocean Node URL or peer id to query; defaults toNODE_URL) -
computeStreamableLogs:
-
stopCompute:
-d, --dataset <datasetDid>
-j, --job <jobId>
-a, --agreement [agreementId] -
getJobStatus:
-d, --dataset <datasetDid>
-j, --job <jobId>
-a, --agreement [agreementId] -
downloadJobResults:
-j, --job <jobId>
-i, --index <index>
-f, --folder [destinationFolder] -
mintOcean:
No options/arguments required. -
generateAuthToken:
No options/arguments required. -
invalidateAuthToken:
-t, --token <token> -
depositEscrow:
-t, --token <token>
-a, --amount <amount> -
getUserFundsEscrow:
-t, --token <token> -
withdrawFromEscrow:
-t, --token <token>
-a, --amount <amount> -
authorizeEscrow:
-t, --token <token>
-p, --payee <payee>
-m, --maxLockedAmount <maxLockedAmount>
-s, --maxLockSeconds <maxLockSeconds>
-c, --maxLockCounts <maxLockCounts> -
getAuthorizationsEscrow:
-t, --token <token>
-p, --payee <payee> -
createAccessList:
-n, --name <name>
-s, --symbol <symbol>
-u, --initial-users [initialUsers](Default:'')
-t, --transferable [transferable](Default:false) -
addToAccessList:
-a, --address <accessListAddress>
-u, --users <users> -
checkAccessList:
-a, --address <accessListAddress>
-u, --users <users> -
removeFromAccessList:
-a, --address <accessListAddress>
-u, --users <users> -
createBucket:
Positional only:[accessListAddress](optional; omit for owner-only access) -
addFileToBucket:
Positional only:<bucketId> <filePath> [fileName] -
listBuckets:
-o, --owner <address>(Optional; defaults to signer) -
listFilesInBucket:
Positional only:<bucketId> -
getFileObject:
Positional only:<bucketId> <fileName> -
deleteFile:
Positional only:<bucketId> <fileName> -
downloadNodeLogs:
-o, --output <output>
-l, --last [last](Hours from now; use eitherlastorfrom/to)
-f, --from [from](Start time, epoch ms)
-t, --to [to](End time, epoch ms)
-m, --maxLogs [maxLogs](Default: 100, max: 1000)
Note:
- When using named options, you can write them in any order.
- When relying on positional arguments, ensure they follow the exact order as defined by the command.
This flexible approach lets you use the style that best suits your workflow while remaining fully backwards compatible.
Copyright ((C)) 2025 Ocean Protocol Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
