Skip to content
LogoLogo

Reading assets

Get at a DDO v5 document without hard-coding its shape

DDO v5 is a W3C Verifiable Credential. Everything that used to sit at the top of the document now lives under credentialSubject, and the indexer's derived data is kept separate from what the publisher signed.

You can index into that structure. You should not — a future DDO v6 would break every one of those paths. nautilus exports a reader for each field instead, and each one goes through ddo-js's DDOManager, so a version bump is absorbed in one place.

asset.metadata.name        // v1, and now wrong
getMetadata(asset).name    // v2

The common ones

const  = await .('did:ope:1234abcd...')
 
const  = () 
const  = () 
const  = () 
 
.(., [0]., )

Every reader

Identity

FunctionReturns
getDid(ddo)string — the asset's did:ope:…
getNftAddress(ddo)string
getOwner(ddo)string | undefined — from indexed NFT data
getIssuer (via the document)the DID or address that signed the credential

Content

FunctionReturns
getMetadata(ddo)MetadataV5
getServices(ddo)ServiceV5[]
getService(ddo, serviceId)ServiceV5 | undefined
getServiceByType(ddo, type)ServiceV5 | undefined — 'access' or 'compute'
getServiceIndex(ddo, serviceId)number

Indexed data

Derived by the indexer, not signed by the publisher.

FunctionReturns
getIndexedMetadata(ddo)IndexedMetadata | undefined
getNft(ddo)the indexed NFT record
getDatatokens(ddo)AssetDatatoken[]
getDatatokenForService(ddo, serviceId)string | undefined
getStatsForService(ddo, serviceId)order counts and prices
getLifecycleState(ddo)number | undefined

Credentials

FunctionReturns
getCredentials(ddo)DdoCredentials — asset-level gating
getServiceCredentials(service)DdoCredentials — per-service gating

Versioning

FunctionReturns
getVersion(ddo)string | undefined
isVersionGte(version, minimum)boolean
supportsSsi(ddo)boolean
asVersioned(ddo)a VersionedDDO wrapper

Picking a service

Most assets have one service and you can take the first. When they have several, select deliberately rather than by index.

const  = await .('did:ope:1234abcd...')
 
// By type — what `access()` and `compute()` do when you omit `serviceId`.
const  = (, 'compute') 
 
// Or inspect them all.
for (const  of ()) {
  .(., ., .)
}

Price and stats

const  = await .('did:ope:1234abcd...')
const  = ()[0].
 
const  = (, ) 
const  = (, ) 

The datatoken address is what pricing reads from the chain.

Searching

To find assets rather than read one, use query, which sends raw Elasticsearch DSL to the node's index.

Try it

npm start -- asset:inspect did:ope:…     # the asset as the node has indexed it

See Examples for the rest of the CLI.