> For the complete documentation index, see [llms.txt](https://docs.oceanprotocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oceanprotocol.com/developers/ddo.js/retrieve-fields.md).

# DDO Fields interactions

After creating DDO instance based on DDO's version, we can interact with the DDO fields through the following methods:

* `getDDOFields()` which returns DDO fields such as:
  * **id**: The Decentralized Identifier (DID) of the asset.
  * **version**: The version of the DDO.
  * **metadata**: The metadata describing the asset.
  * **services**: An array of services associated with the asset.
  * **credentials**: An array of verifiable credentials.
  * **chainId**: The blockchain chain ID where the asset is registered.
  * **nftAddress**: The address of the NFT representing the asset.
* `getAssetFields()` which returns Asset fields such as:

  * **datatokens** (optional): The datatokens associated with the asset.
  * **indexedMetadata** (optional): Encapsulates data about blockchain asset related event, NFT, stats (pricing of the asset, number of orders per asset), purgatory (if the asset belongs or not in the purgatory).
    * **event** (optional): The last event related to the asset.
    * **nft** (optional): Information about the NFT representing the asset.
    * **purgatory** (optional): Purgatory status of the asset, if applicable.
    * **stats** (optional): Statistical information about the asset (e.g., usage, views).**Example of indexedMetadata**

  ```json
   indexedMetadata: {
     event: {
       txid: '0xceb617f13a8db82ba9ef24efcee72e90d162915fd702f07ac6012427c31ac952',
       block: 39326976,
       from: '0x0DB823218e337a6817e6D7740eb17635DEAdafAF',
       contract: '0xBB1081DbF3227bbB233Db68f7117114baBb43656',
       datetime: '2023-02-15T16:42:22'
     },
     nft: {
       address: '0xBB1081DbF3227bbB233Db68f7117114baBb43656',
       name: 'Ocean Data NFT',
       symbol: 'OCEAN-NFT',
       state: 0,
       tokenURI:
         'data:application/json;base64,eyJuYW1lIjoiT2NlYW4gRGF0YSBORlQiLCJzeW1ib2wiOiJPQ0VBTi1ORlQiLCJkZXNjcmlwdGlvbiI6IlRoaXMgTkZUIHJlcHJlc2VudHMgYW4gYXNzZXQgaW4gdGhlIE9jZWFuIFByb3RvY29sIHY0IGVjb3N5c3RlbS5cblxuVmlldyBvbiBPY2VhbiBNYXJr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-30T08:40:43'
     },
     purgatory: {
       state: false
     },
     stats: [
       {
           datatokenAddress: "0x34e84f653Dcb291838aa8AF8Be1E1eF30e749ba0",
           name: "BDT2",
           symbol: "DT2",
           serviceId: "1",
           orders: 5,
           prices: [
                       {  
                           type: "fixedrate", 
                           price: "1",
                           token:"0x967da4048cD07aB37855c090aAF366e4ce1b9F48",
                           contract: "freContractAddress", 
                           exchangeId:  "0x23434" 
                       }
                   ]
       }
     ]
   }
  ```
* `getDDOData()` which simply retruns as `Record<string, any>` the full DDO structure including DDO and Asset fields.
* `getDid()` which returns only the Decentralized Identifier (DID), as `string`, of the asset.

## Usage of DDO Manager Functions

Now let's use [DDO V4 example](/developers/ddo.js/instantiate-ddo.md#usage-examples), `DDOExampleV4` into the following javascript code, assuming `@oceanprotocol/ddo-js` has been installed as dependency before:

```javascript
const { DDOManager } = require ('@oceanprotocol/ddo-js');

const ddoInstance = DDOManager.getDDOClass(DDOExampleV4);

// DDO V4
console.log('DDO V4 Fields: ', ddoInstance.getDDOFields());
// Individual fields access
console.log('DDO V4 chain ID: ', ddoInstance.getDDOFields().chainId);
console.log('DDO V4 Asset Fields: ', ddoInstance.getAssetFields());
console.log('DDO V4 Data: ', ddoInstance.getDDOData());
console.log('DDO V4 DID: ', ddoInstance.getDid());

// The same script can be applied on DDO V5 and deprecated DDO from `Instantiate DDO section`.
```

**Execute script**

```bash
node retrieve-ddo-fields.js
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.oceanprotocol.com/developers/ddo.js/retrieve-fields.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
