compute
Start a paid Compute-to-Data job.
Usage
const { } = await .({
: { : 'did:ope:1234abcd...' },
: { : 'did:ope:5678wxyz...' }
})
const = [0].What happens in order:
- Every input is resolved and its compute service selected.
- Credentials are satisfied for all inputs. A failure here aborts the whole job with nothing spent — the reason this comes first.
initializeComputequotes the job: provider fees, reusable orders and the escrow amount.- Escrow is funded and the environment authorised to draw the quoted amount.
- Each input is ordered — reusing an existing order where the node says one is valid.
- The job starts.
Choosing an environment
v1 silently used the node's first environment. Prefer choosing deliberately, since resources, duration limits and fees differ:
const = await .()
const = [0]
const { } = await .({
: { : 'did:ope:1234abcd...' },
: { : 'did:ope:5678wxyz...' },
: .,
: [
{ : 'cpu', : 2 },
{ : 'ram', : 2 }
]
})Returns
- Type:
ComputeResult
Properties
jobs
- Type:
ComputeJob[]
The started jobs. Poll them with getComputeStatus.
environment
- Type:
ComputeEnvironment
The environment the job actually runs in, including the one nautilus picked for you.
initializeResults
- Type:
ProviderComputeInitializeResults
What the node quoted: per-input provider fees and reusable orders, plus the escrow payment.
orders
- Type:
Record<string, string>
The order transaction backing each input, keyed by did#serviceId so two inputs on the same asset keep separate orders.
Parameters
config
- Type:
ComputeConfig
Properties
dataset
- Type:
ComputeAssetRef
{ did, serviceId?, userdata? }. Defaults to the asset's first compute service.
algorithm
- Type:
ComputeAlgorithmRef
ComputeAssetRef plus algocustomdata? and envs? (environment variables for the
container).
additionalDatasets (optional)
- Type:
ComputeAssetRef[]
Extra inputs. C2D v2 passes every dataset in one array; nautilus assembles that for you.
computeEnv (optional)
- Type:
string
Environment id. Defaults to the node's first, which is logged when it happens.
resources (optional)
- Type:
ComputeResourceRequest[]
[{ id: 'cpu', amount: 2 }]. Ids come from ComputeEnvironment.resources. Defaults to
each resource's declared minimum.
paymentToken (optional)
- Type:
string
Must be a token the environment prices for this chain — fees is keyed by chain id.
Defaults to the first accepted token; an unaccepted one fails with the list of accepted ones.
maxJobDuration (optional)
- Type:
number
Seconds. Capped to the environment's maxJobDuration, with a warning when it is.
output (optional)
- Type:
ComputeOutput
{ remoteStorage?, encryption? }. v1's hardcoded publishAlgorithmLog and publishOutput
flags no longer exist.
outputBucketId (optional)
- Type:
string
Store results in an ocean-node bucket instead. Mutually exclusive with output.
additionalViewers (optional)
- Type:
string[]
Extra addresses allowed to read the results.
metadata (optional)
- Type:
Record<string, string | number | boolean>
queueMaxWaitTime (optional)
- Type:
number
Seconds to wait in the queue when resources are unavailable.
skipCredentials (optional)
- Type:
boolean