Ocean Node client
The escape hatch under every nautilus call
In v1 there were two services: Aquarius for metadata and Provider for everything else. v2
talks to a single ocean-node, which serves metadata, provider services, the indexer and
compute — which is why metadataCacheUri and providerUri collapsed into one
oceanNodeUri.
Most of the time nautilus wraps this for you. When it does not, take the client.
const = .()
const = await .()Checking what you are pointed at
Worth doing first when something behaves unexpectedly — a v1 Provider and an ocean-node answer on the same port but are not the same thing.
const = .()
const = await .()
const = await .() Authentication
The client accepts three forms of auth, expressed as NodeAuth:
| Form | When |
|---|---|
Signer | The default. Each call does a nonce-and-sign round trip. |
| JWT auth token | Skips that round trip. Requires consumerAddress, because nautilus cannot decode the token. |
| Pre-computed signature | You already hold { consumerAddress, signature, nonce }. |
Minting a token is worth it for anything doing many calls:
const = await (, )
// … many calls later
await (, , ) Calls nautilus does not wrap
Files
// What the node can see about a file, before you publish it.
const = await .(
{ : 'url', : 'https://data.example/x.csv', : 'GET' } as never
)
// Whether a published asset's files are still readable.
const = await .('did:ope:1234abcd...', 'service-id') checkDidFiles is the quickest way to find out whether an asset has rotted — a file server
that went away shows up here rather than at download time.
Buckets
The node's persistent storage, which is what
NodePersistentRemoteStore uses underneath.
const = await .([], 'my-bucket')
// `content` is a request body stream, not a string — a web `ReadableStream`,
// a Node stream or a `Blob` all work.
await .(, 'notes.txt', new (['hello']).())
const = await .(, 'notes.txt')Remote validation
Local validation is what publish runs. If you also want the
node's opinion:
const = await .() Errors
Every call is wrapped, so failures arrive as OceanNodeError with the operation named and
the original error kept on cause.
try {
await ()
} catch () {
if ( instanceof ) {
.(., ., .)
}
}Building one directly
You rarely need to — Nautilus.create builds it — but the constructor is public.
const = new ({
: 'https://ocean-node.dev.pontus-x.eu',
: 32456,
:
})nodeUri also accepts a peerId or multiaddr, which switches it to the libp2p transport.