---
description: Data resource exchange platform
---

# Marketplace

{% hint style="info" %}
This model allows one to register a marketplace and then register off-chain resources or data to the platform to allow exchange between the provider and the consumer. The exchange process of the All the roles and components described below have been defined in, and are derived from the [**Generic Resource Exchange Protocol (GREP)**](../grep). Please refer to the protocol specifications for more details.
{% endhint %}

## Marketplace Resources

The marketplace basically facilitates resource exchange on an open platform.

The process one would follow to enable the marketplace to be able to publish resources can briefly be outlined in the following manner:

#### 1. Domain registration

The domain that helps identify the marketplace needs to be registered on the blockchain and in the Ontology system. It involves these steps:

* **ONT ID registration:** Identifies the marketplace and the owner
* **Payer registration:** Account that pays the operation costs
* **ONS registration:** Registering the domain name on the Ontology name server

#### 2. Marketplace setup

You may choose to use the [**Ontology generic marketplace server**](marketplace/saas-tenant) for your solution, or [**deploy your own**](marketplace/deployment). The next step would be configure the marketplace you deployed.

#### 3. SDK invocation

Link to the [**data storage provider**](data-storage) by invoking the marketplace SDK in your application. The ONT ID for your application also needs to be enabled at this point.

#### 4. Resource auditors

Choose the [**resource auditors**](resource-auditor) and [**offline judgers**](offline-judge) for your marketplace platform.

## Marketplace Runtime

The process to enable the marketplace for your end users is as follows:

### 1. Calling resource data mapping and upload&#x20;

The RP needs to set up a storage service for the data resources that are to be published on the marketplace. Once the storage service is in place, the marketplace API or SDK methods can be used to generate `DataId` for the respective data items and then link them to the marketplace platform using this ID.

### 2. Fetching a claim from the resource auditor

The RP needs to fetch a verifiable [**claim**](../../../../glossary#claim) from their resource auditor.

### 3. Generating a data identifier

Use the marketplace API or SDK method to fetch the QR code to authenticate the `DataId` for the respective data items using [**ONT Auth**](../../../../discover#ontology-authenticator).

The SDK method or the API can be used to confirm if the authentication was successful. If the authentication is successful, the platform automatically links the `DataId` and the respective data resources.

### 4. Choose a marketplace model&#x20;

There are two marketplace models available currently.

#### Pay-as-you-go

**pay-as-you-go** model is as such:

1. The **RP** needs to link the `DataId` with the resources after pre-uploading the data
2. &#x20;**RP** uploads the data and passes the necessary parameters to generate the token
3. The **RC** makes a purchase on the marketplace, the token is generated, and the ownership is transferred to the **RC**
4. RC can use the token to gain access to the data resource and the meta data
5. Once the purchase is deemed successful, the transaction costs are allocated to the marketplace as per the fixed policy

#### Pre-order&#x20;

This model involves generating DTokens to carry out transfer of off-chain data on the data storage provider.  The exchange process of the **pre-order** model is as such:

1. The **RP** needs to generate and link the `DataId` with the resources after pre-uploading the data
2. After the `DataId` is generated, the parameters to generate the DToken need to be passed, such as the amount of tokens to be generated, etc.
3. The `DataId` and DToken are linked and the data is uploaded to the platform
4. The **RC** can make a purchase by choosing to either buy all the tokens, or a certain amount with respect to a particular resource
5. **RC** uses the token to access the resource meta data
6. Once the purchase is deemed successful, the transaction costs are allocated to the marketplace as per the fixed policy

Publishing a resource on the marketplace platform consists of the following steps:

1. Data quality verification
2. Publishing the meta data
3. Publishing the price
4. Lock the safety deposit to the marketplace smart contract
5. Define a offline judger candidate list for the transaction contract
6. Publish the resource on the platform

### 5. DToken exchange

In the case of an [**E-shop**](../use-cases/e-shops), carrying out a transaction with would involve token generation using the passed parameters which would determine the total volume of the tokens, the contract is then invoked and the action can be authenticated using [**ONT Auth**](../../../../discover#ontology-authenticator).

**Sample Parameters:**

```javascript
{
  dataId: "did:ont:aaaaaaa", // Data ontid
  ontid: ontid, // RP ontid
  pubKey: 1,
  contractVo: {
    argsList: [{
      name: "account",
      value: "Address:aaaaaaa" // wallet address
    }, {
      name: "dataId",
      value: "String:" + dataId // data ontid
    }, {
      name: "ontid",
      value: "String:" + ontid	// RP ontid
    }, {
      name: "index",
      value: 1
    }, {
      name: "symbol",
      value: "String:aaa"
    }, {
      name: "name",
      value: "String:aaa"
    }, {
      name: "amount",  // Token amount to be generated
      value: 12
    }, {
      name: 'transferCount',
      value: 12
    }, {
      name: 'accessCount',
      value: 12
    }, {
      name: 'expireTime',
      value: 16121212		// Token expiration time
    }],
    contractHash: "06633f64506fbf7fd4b65b422224905d362d1f55",	// contract hash
    method: "createTokenWithController",	// contract method
  }
}
```

The API can be used to verify the authentication result. The QR code parameters can be fetched using the SDK method or the [**storage API**](../../../developer-tools/api/ddxf/storage-api)**.** After the `DataId` and the tokens are linked the data can finally be uploaded to the platform.

Once the RC makes a purchase, the transaction will be carried out with the token amount selected. In data mode, the defined amount of tokens will be generated and the ownership will be transferred to the RC.

### 6. Incentive sharing

Incentives and profit are shared based on the respective fixed policies. Please refer to the [**resource incentive sharing**](../../overall-scheme#resource-incentive-sharing) section in the over all scheme for details.

### 7. Transaction evaluation and rating

After the transaction is completed, the **RP** and the **RC** review each other. The review can be about the resources or users. The **MP** can provide a review system and the post-transaction reviews are stored in the **MP**'s local database. When the on-chain review system is well-established, the **MP** can use a combination of the on-chain review system and local review system to present a more accurate rating.

## Hosting a Resource Exchange Platform

#### Step 1: Deployment

Refer to the link below for details on marketplace deployment process.

{% content-ref url="marketplace/deployment" %}
[deployment](marketplace/deployment)
{% endcontent-ref %}

#### Step 2: Smart Contract API Integration

For API and SDK reference please follow the links below.

{% content-ref url="../../../developer-tools/api/ddxf/marketplace-api" %}
[marketplace-api](../../../developer-tools/api/ddxf/marketplace-api)
{% endcontent-ref %}

{% content-ref url="../../../developer-tools/api/ddxf/storage-api" %}
[storage-api](../../../developer-tools/api/ddxf/storage-api)
{% endcontent-ref %}

#### Step 3: Marketplace SDK Invocation

Please follow [**this**](https://github.com/ont-bizsuite/marketplace-addon) link to access the Java SDK repository.

#### Step 4: Proceed with the flow specific to your scenario

