Nautilus
The instance that enables all data economy interactions
Every interaction goes through a Nautilus instance. It holds three things — an ethers
Signer, a resolved chain Config, and an
ocean-node client — and every method reuses them, which is why no
call takes a signer, chainConfig or providerUri the way v1's did.
Creating an instance
The constructor is private: the chain config has to be resolved from the signer's network before the instance is usable, and that is asynchronous. Use the static factory.
import { , } from 'ethers'
import { } from '@deltadao/nautilus'
const = new ('https://rpc.dev.pontus-x.eu')
const = new ('0x...', )
const = await .(, {
: { : 'https://ocean-node.dev.pontus-x.eu' }
}) See create for the full option reference.
The two-step bootstrap
The credentials option needs an OceanNodeClient. You can
construct one yourself with the node URI, chain id and
auth, but the simplest way is to let an instance resolve all of that from the signer and
the config: build a throwaway instance first, take its client, and pass it to the real one.
const = await .(, { })
const = await .(, {
,
: new ({ : 'http://127.0.0.1:5001/api/v0/add' }),
: new (.(), {
: 'https://wallet.example.org'
})
})NautilusOptions
| Option | Type | Purpose |
|---|---|---|
config | Partial<Config> | Overrides merged over the chain config resolved from the signer's network. oceanNodeUri is effectively required. |
remoteStore | RemoteStore | Where the encrypted DDO envelope is stored. Required to publish — nautilus writes an encrypted {remote} pointer on chain, not the document. Use IpfsRemoteStore or S3RemoteStore; NodePersistentRemoteStore is rejected. See remote stores. |
ddoSigner | DdoSigner | Signs the DDO as a verifiable credential. Defaults to the Ethereum key (ETH-EIP191). See signing. |
credentials | CredentialProvider | Answers the presentation request of an asset whose SSIpolicy asks for credentials. Not needed for address-only gates. See credential-gated assets. |
sessionStore | SessionStore | Where policy-server sessions are cached. Defaults to a MemorySessionStore. Gets only sessions opened without a presentation, unless persistPresentedSessions. |
persistPresentedSessions | boolean | Also keep presented sessions in sessionStore. Default false: their ids give read access to the presentation. |
sessionTtlMs | number | How long a cached policy-server session is reused, in ms. Defaults to 2 minutes; 0 caches nothing. |
allowInsecureTransport | boolean | Accept a plain http:// oceanNodeUri on a host other than localhost, 127.0.0.0/8, ::1 or *.localhost. Default false. See create. |
PublishOptions
Accepted by both publish and edit.
| Option | Type | Default | Purpose |
|---|---|---|---|
waitForIndexer | boolean | { intervalMs?, timeoutMs? } | false | Block until the indexer has the asset, so the result is immediately resolvable. Throws an IndexingError if the node records a failure, and an OceanNodeError on timeout. Defaults: 7 s interval (under the node's default rate limit), 5 min timeout. Either error carries the full response as error.published. |
remoteStore | RemoteStore | instance's | Override the remote store for this call. |
ddoSigner | DdoSigner | instance's | Override the DDO signer for this call. |
checkIndexerNonce | boolean | true | Before the first transaction, throw an IndexerNonceStuckError when the node would not accept its indexer's next decrypt call, so the asset would not be indexed. Skipped silently when the node does not answer. See publish. |
There is no encrypt option: the pointer and the stored envelope are always node-encrypted
(flags 0x02), and encrypt: false throws. Also accepted by
completePublish.
Method reference
Static
Accessors
getOceanConfig ·
getNodeClient ·
getSigner ·
setCredentialProvider
Metadata
getAsset ·
getAssets ·
query ·
waitForIndexer
Publishing and editing
publish ·
completePublish ·
edit ·
setServicePrice ·
setAssetLifecycleState
Access
Compute
getComputeEnvironments ·
getComputeEnvironment ·
compute ·
freeCompute ·
getComputeStatus ·
getComputeResult ·
streamComputeResult ·
getComputeLogs ·
stopCompute
Job ids
A job id is <environmentHash>-<jobId>: the hash of the node's compute engine, which is
also the first segment of the environment id, then the job's own id. compute and
freeCompute return it, every job method takes it, and getComputeStatus reports the job
under it. ocean-node addresses a job that way, and asked for the status of a bare id it
lists every job of the consumer, so a bare id throws.