> For the complete documentation index, see [llms.txt](https://docs.oncompute.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oncompute.ai/ocean-cli/editor.md).

# Everyday Commands

**Note**: All commands are run using `npm run cli <command>`. Ensure you have your `PRIVATE_KEY`, `RPC`, and `NODE_URL` environment variables set or please follow the Installation steps first.

### 1. Publishing Assets

Publish a dataset or algorithm to the network.

```bash
# Publish a dataset defined in a JSON file
npm run cli publish metadata/my-dataset.json

# Publish an algorithm defined in a JSON file
npm run cli publishAlgo metadata/my-algorithm.json
```

*Tip: Make sure your metadata JSON follows the Ocean DDO standard.*

### 2. Paid Compute Flow (Step-by-Step)

This guide walks you through running a paid compute job on a remote node.

#### Step 1: Find a Compute Environment

First, find out which compute environments (Docker images) are available on your chosen node.

```bash
# List all environments
npm run cli getComputeEnvironments

# (Advanced) Get the ID of the first environment using jq
npm run cli getComputeEnvironments | awk 'FNR==7 { print }' | awk '{$1=$2=$3="";print $0}' | jq '.'
```

#### Step 2: Start the Compute Job

Use the `startCompute` command. You will need:

* Dataset DID
* Algorithm DID
* Environment ID (from Step 1)
* Max Job Duration (in seconds)
* Payment Token Address (e.g., USDC)
* Resources (CPU, RAM, Disk)

```bash
# Example: Start a job with 60s timeout using USDC
export PAYMENT_TOKEN="0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238" 

npm run cli -- startCompute \
  $DATASET_DID \
  $ALGO_DID \
  $ENV_ID \
  60 \
  $PAYMENT_TOKEN \
  '[{"id":"cpu","amount":1},{"id":"disk","amount":1},{"id":"ram","amount":1}]'
```

*Note: The CLI will prompt you to confirm the payment. Use `--accept true` to auto-confirm.*

#### Step 3: Check Job Status

Monitor the progress of your job.

```bash
# Check status (Running, Finished, etc.)
npm run cli getJobStatus -d $DATASET_DID -j $JOB_ID ''
```

#### Step 4: Download Results

Once the job is finished, download the results (logs and output files).

```bash
# Download results to a local folder
mkdir results
npm run cli downloadJobResults $JOB_ID 2 ./results
```

### 3. Other Common Commands

#### Consuming Data (Download)

Download a dataset you have access to.

```bash
# Download by DID
npm run cli download --did did:op:0x123... --folder ./my-downloads
```

#### Managing Assets

**Edit Metadata:**

```bash
npm run cli editAsset --did did:op:0x123... --file updated-metadata.json
```

**Allow/Disallow Algorithms:** Control which algorithms can run on your dataset.

```bash
npm run cli allowAlgo --dataset did:op:DATASET_ID --algo did:op:ALGO_ID
```

#### Access Lists (Whitelisting)

**Create Access List:**

```bash
npm run cli createAccessList --name "My Whitelist" --symbol "MWL" --users "0xUser1...,0xUser2..."
```

**Add Users:**

```bash
npm run cli addToAccessList --address 0xAccessListContract --users "0xUser3..."
```

**Check Access:**

```bash
npm run cli checkAccessList --address 0xAccessListContract --users "0xUser1..."
```

**Persistent Storage**

Manage storage buckets and access lists on Ocean nodes. See Persistent Storage with Ocean CLI for a full command reference and end-to-end walkthrough

```bash
# Bucket and file management
npm run cli createBucket [accessListAddress]
npm run cli listBuckets
npm run cli listFilesInBucket <bucketId>
npm run cli addFileToBucket <bucketId> <filePath>
npm run cli getFileObject <bucketId> <fileName>
npm run cli deleteFile <bucketId> <fileName>
```

#### Escrow Management

**Deposit Funds:**

```bash
npm run cli depositEscrow --token 0xTokenAddress --amount 100
```

**Check Balance:**

```bash
npm run cli getUserFundsEscrow --token 0xTokenAddress
```

**Withdraw Funds:**

```bash
npm run cli withdrawFromEscrow --token 0xTokenAddress --amount 50
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.oncompute.ai/ocean-cli/editor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
