Skip to main content

DDO

@nevermined-io/sdk - v3.0.19 / DDO

Class: DDO

DID Descriptor Object (DDO). Contains all the metadata related to an asset, including the description and the services available.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DDO(ddo?): DDO

Parameters

NameType
ddoPartial\<DDO>

Returns

DDO

Defined in

src/ddo/DDO.ts:232

Properties

@context

@context: string = 'https://w3id.org/did/v1'

Defined in

src/ddo/DDO.ts:209


_nvm

_nvm: NvmConfig

Defined in

src/ddo/DDO.ts:218


authentication

authentication: Authentication[] = []

Defined in

src/ddo/DDO.ts:226


created

created: string

Defined in

src/ddo/DDO.ts:220


didSeed

didSeed: string = ''

Defined in

src/ddo/DDO.ts:216


id

id: string = ''

DID, decentralizes ID.

Defined in

src/ddo/DDO.ts:214


proof

proof: Proof

Defined in

src/ddo/DDO.ts:230


publicKey

publicKey: PublicKey[] = []

Defined in

src/ddo/DDO.ts:224


service

service: ServiceCommon[] = []

Defined in

src/ddo/DDO.ts:228


updated

Optional updated: string

Defined in

src/ddo/DDO.ts:222

Methods

addDefaultMetadataService

addDefaultMetadataService(metadata, nftAttributes?): MetaDataMain

Adds a default metadata service to the DDO.

Parameters

NameTypeDescription
metadataMetaDatametadata
nftAttributes?NFTAttributesnft attributes

Returns

MetaDataMain

main metadata attributes

Defined in

src/ddo/DDO.ts:474


addProof

addProof(publicKey): Promise\<void>

Generates and adds a proof using personal sign on the DDO.

Parameters

NameTypeDescription
publicKeystringPublic key to be used on personal sign.

Returns

Promise\<void>

void.

Defined in

src/ddo/DDO.ts:424


addService

addService(service): void

Adds a service to the DDO.

Parameters

NameType
serviceServiceCommon

Returns

void

Defined in

src/ddo/DDO.ts:446


addSignature

addSignature(nevermined, publicKey): Promise\<void>

It adds a signature to the the proof object of the DDO

Parameters

NameTypeDescription
neverminedNeverminednevermined object
publicKeystringpublic key to sign the DDO

Returns

Promise\<void>

Defined in

src/ddo/DDO.ts:556


assignDid

assignDid(didSeed, didRegistry, publisher): Promise\<void>

Assign a DID to the DDO

Parameters

NameTypeDescription
didSeedstringDID seed
didRegistryDIDRegistryDIDRegistry contract
publisherNvmAccountaccount registering the DID

Returns

Promise\<void>

Defined in

src/ddo/DDO.ts:534


checksum

checksum(seed): string

Parameters

NameType
seedstring

Returns

string

Defined in

src/ddo/DDO.ts:386


findServiceByIndex

findServiceByIndex\<T>(index): Service\<T>

Finds a service of a DDO by index number.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
indexnumberindex of the service in the DDO.

Returns

Service\<T>

Service.

Defined in

src/ddo/DDO.ts:291


findServiceByReference

findServiceByReference\<T>(serviceReference): Service\<T>

Finds a service of a DDO by index.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceReferencenumber | ServiceTypereference to the service (index or type).

Returns

Service\<T>

Service.

Defined in

src/ddo/DDO.ts:325


findServiceByType

findServiceByType\<T>(serviceType): Service\<T>

Finds the first service of a DDO by type.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceTypeTService type used by find the service

Returns

Service\<T>

Service.

Throws

DDOServiceNotFoundError If the service is not in the DDO.

Defined in

src/ddo/DDO.ts:311


generateDidSeed

generateDidSeed(seed): Promise\<`0x${string}`>

It generates a DID seed from a seed

Parameters

NameTypeDescription
seedanythe seed

Returns

Promise\<`0x${string}`>

the string represeing the DID seed

Defined in

src/ddo/DDO.ts:547


generateProof

generateProof(publicKey): Promise\<Proof>

Generates proof using personal sign.

Parameters

NameTypeDescription
publicKeystringPublic key to be used on personal sign.

Returns

Promise\<Proof>

Proof object.

Defined in

src/ddo/DDO.ts:395


getAssetPriceFromDDOByServiceType

getAssetPriceFromDDOByServiceType(service): AssetPrice

It gets the AssetPrice from a service given the serviceType

Parameters

NameTypeDescription
serviceServiceTypethe service to search in

Returns

AssetPrice

the AssetPrice object

Defined in

src/ddo/DDO.ts:711


getPriceByService

getPriceByService(serviceType?): bigint

Get the total price of a service.

Parameters

NameTypeDefault valueDescription
serviceTypeServiceType'access'Service type

Returns

bigint

bigint

Example

const price = ddo.getPriceByService('nft-access')

Throws

DDOPriceNotFoundError

Defined in

src/ddo/DDO.ts:376


getProofChecksum

getProofChecksum(): string

Get the checksum of the proof.

Returns

string

string containing the checksum of the proof.

Defined in

src/ddo/DDO.ts:415


getServicesByType

getServicesByType\<T>(serviceType): Service\<T>[]

Gets all the services of a DDO with a specific type.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceTypeTService type.

Returns

Service\<T>[]

Service.

Defined in

src/ddo/DDO.ts:341


reorderServices

reorderServices(): void

It reorders the services of the DDO using the service index

Returns

void

Defined in

src/ddo/DDO.ts:434


replaceService

replaceService(index, service): void

Replaces a service in the DDO.

Parameters

NameType
indexnumber
serviceany

Returns

void

Defined in

src/ddo/DDO.ts:462


serviceExists

serviceExists\<T>(serviceType): boolean

Checks if a service exists in the DDO.

Type parameters

NameType
Textends ServiceType

Parameters

NameTypeDescription
serviceTypeTService type.

Returns

boolean

true if service exists.

Defined in

src/ddo/DDO.ts:351


serviceIndexExists

serviceIndexExists(serviceIndex): boolean

Checks if a service index in the DDO.

Parameters

NameTypeDescription
serviceIndexnumberService index.

Returns

boolean

true if service exists.

Defined in

src/ddo/DDO.ts:361


setAssetPriceFromDDOByService

setAssetPriceFromDDOByService(serviceType, rewards): void

Given a service type, it sets the AssetPrice in the escrowPayment condition

Parameters

NameTypeDescription
serviceTypeServiceTypethe service to search in
rewardsAssetPricethe AssetPrice object to set

Returns

void

Defined in

src/ddo/DDO.ts:721


setNFTRewardsFromService

setNFTRewardsFromService(serviceType, rewards, holderAddress): undefined | DDOConditionNotFoundError

Given the service type it sets the AssetPrice and NFT holder

Parameters

NameTypeDescription
serviceTypeServiceTypethe service type to search in
rewardsAssetPricethe AssetPrice object to set
holderAddressstringthe NFT Holder address to set

Returns

undefined | DDOConditionNotFoundError

Defined in

src/ddo/DDO.ts:748


shortId

shortId(): string

It returns the DDO id without the prefix

Returns

string

the DID without the prefix

Defined in

src/ddo/DDO.ts:282


updateMetadataService

updateMetadataService(service): void

Updates a service in the DDO

Parameters

NameTypeDescription
serviceanythe service to be updated

Returns

void

Defined in

src/ddo/DDO.ts:520


updateService

updateService(service, serviceIndex?): void

Parameters

NameTypeDefault valueDescription
serviceanyundefinedthe service to be updated
serviceIndexnumber0the position of the service in the DDO.services array

Returns

void

Deprecated

use the updateMetadataService or replaceService methods instead Updates a service in the DDO

Defined in

src/ddo/DDO.ts:511


createAuthorizationService

createAuthorizationService(neverminedNodeUri, publicKey, method): ServiceCommon

It creates an authorization service that can be included later as part of a DDO

Parameters

NameTypeDescription
neverminedNodeUristringURL of the Nevermined Node managing this asset
publicKeystringPublic key of the user
methodstringEncryption method

Returns

ServiceCommon

The authorization service

Defined in

src/ddo/DDO.ts:190


deserialize

deserialize(ddoString): DDO

Deserializes the DDO object.

Parameters

NameTypeDescription
ddoStringstringThe serialized DDO to be deserialized.

Returns

DDO

The deserialized DDO.

Defined in

src/ddo/DDO.ts:177


findAndReplaceDDOAttribute

findAndReplaceDDOAttribute(ddo, paramName, value): DDO

Finds an attribute in the DDO and replace it with the given value

Parameters

NameTypeDescription
ddoDDOthe originial DDO
paramNamestringthe param name to replace
valuestringthe new value

Returns

DDO

the DDO with the replaced attribute

Defined in

src/ddo/DDO.ts:771


findServiceConditionByName

findServiceConditionByName(service, name): ServiceAgreementTemplateCondition

If fins a service condition by name

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in
nameConditionTypethe name of the condition

Returns

ServiceAgreementTemplateCondition

ServiceAgreementTemplateCondition the condition

Defined in

src/ddo/DDO.ts:568


getAssetPriceFromService

getAssetPriceFromService(service): AssetPrice

It gets the AssetPrice from a service with escrowPayment condition

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

AssetPrice

the AssetPrice object

Defined in

src/ddo/DDO.ts:686


getDIDFromService

getDIDFromService(service): string

Gets the DID in the escrowPayment condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

string

the DID

Defined in

src/ddo/DDO.ts:584


getDurationFromService

getDurationFromService(service): number

Gets the duration parameter in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

number

the duration of the subscription

Defined in

src/ddo/DDO.ts:641


getInstance

getInstance(userId, publisherAddress, appId?): DDO

It gets an instance of a DDO with the basic structure

Parameters

NameTypeDescription
userIdstringThe unique identifier of the user
publisherAddressstringThe address of the publisher
appId?stringThe application id

Returns

DDO

a DDO instance

Defined in

src/ddo/DDO.ts:245


getNFTTransferFromService

getNFTTransferFromService(service): boolean

Gets the nftTransfer parameter in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

boolean

if condition will do a nft transfer or a mint

Defined in

src/ddo/DDO.ts:630


getNewDateFormatted

getNewDateFormatted(date?): string

It gets a new date formatted

Parameters

NameTypeDescription
dateDatethe date to format

Returns

string

the date string formatted

Defined in

src/ddo/DDO.ts:274


getNftAmountFromService

getNftAmountFromService(service): bigint

Gets the number of NFTs in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

bigint

the number of NFTs

Defined in

src/ddo/DDO.ts:616


getNftContractAddressFromService

getNftContractAddressFromService(service): string

Gets the NFT Contract address used in the NFT Access or NFT Sales service

Parameters

NameTypeDescription
serviceServiceNFTAccess | ServiceNFTSalesthe service to search in

Returns

string

the NFT contract address

Defined in

src/ddo/DDO.ts:670


getNftHolderFromService

getNftHolderFromService(service): string

Gets the NFT Holder in the transferNFT condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

string

the NFT Holder address

Defined in

src/ddo/DDO.ts:594


getParameterFromCondition

getParameterFromCondition(service, conditionType, paramName): string | number | string[]

Given a service, condition and param name it returns the value

Parameters

NameTypeDescription
serviceServiceCommonThe service where the condition is
conditionTypeConditionTypethe condition type
paramNamestringthe param name

Returns

string | number | string[]

the value

Defined in

src/ddo/DDO.ts:652


getTokenIdFromService

getTokenIdFromService(service): string

Gets the NFT TokenId in the nftHolder condition of the service

Parameters

NameTypeDescription
serviceServiceCommonthe service to search in

Returns

string

the NFT Token Id

Defined in

src/ddo/DDO.ts:603


serialize

serialize(ddo): string

Serializes the DDO object.

Parameters

NameTypeDescription
ddoDDOThe DDO to be serialized.

Returns

string

DDO serialized.

Defined in

src/ddo/DDO.ts:168