mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
GITBOOK-502: change request with no subject merged in GitBook
This commit is contained in:
parent
51b990be6d
commit
250ed3b992
BIN
.gitbook/assets/my-data (1).gif
Normal file
BIN
.gitbook/assets/my-data (1).gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 MiB |
BIN
.gitbook/assets/my-data.gif
Normal file
BIN
.gitbook/assets/my-data.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 MiB |
12
SUMMARY.md
12
SUMMARY.md
@ -31,7 +31,7 @@
|
||||
* [Claim Rewards Data Farming](user-guides/claim-ocean-rewards.md)
|
||||
* [Liquidity Pools \[deprecated\]](user-guides/remove-liquidity-using-etherscan.md)
|
||||
* [👨💻 Developers](developers/README.md)
|
||||
* [Architecture Overview](developers/contracts/architecture.md)
|
||||
* [Architecture Overview](developers/architecture.md)
|
||||
* [Contracts](developers/contracts/README.md)
|
||||
* [Data NFTs](developers/contracts/data-nfts.md)
|
||||
* [Datatokens](developers/contracts/datatokens.md)
|
||||
@ -55,11 +55,11 @@
|
||||
* [Customising a Market](developers/build-a-marketplace/customising-your-market.md)
|
||||
* [Deploying a Market](developers/build-a-marketplace/deploying-market.md)
|
||||
* [Subgraph](developers/subgraph/README.md)
|
||||
* [Get data NFTs](developers/subgraph/list-data-nfts.md)
|
||||
* [Get data NFT information](developers/subgraph/get-data-nft-information.md)
|
||||
* [Get datatokens](developers/subgraph/list-datatokens.md)
|
||||
* [Get datatoken information](developers/subgraph/get-datatoken-information.md)
|
||||
* [Get fixed-rate exchanges](developers/subgraph/list-fixed-rate-exchanges.md)
|
||||
* [Get data NFTs](developers/using-ocean-subgraph/list-data-nfts.md)
|
||||
* [Get data NFT information](developers/using-ocean-subgraph/get-data-nft-information.md)
|
||||
* [Get datatokens](developers/using-ocean-subgraph/list-datatokens.md)
|
||||
* [Get datatoken information](developers/using-ocean-subgraph/get-datatoken-information.md)
|
||||
* [Get fixed-rate exchanges](developers/using-ocean-subgraph/list-fixed-rate-exchanges.md)
|
||||
* [Get veOCEAN stats](developers/subgraph/get-veocean-stats.md)
|
||||
* [List datatoken buyers](developers/subgraph/list-datatoken-buyers.md)
|
||||
* [Ocean.py](developers/ocean.py/README.md)
|
||||
|
@ -1,31 +1,31 @@
|
||||
---
|
||||
description: Ocean Protocol is built by data scientists, for data scientists.
|
||||
cover: ../.gitbook/assets/cover/data_science.png
|
||||
coverY: 0
|
||||
---
|
||||
|
||||
# 📊 Data Science
|
||||
|
||||
\#would be good to edit this beginning part, need to figure out the right language
|
||||
<figure><img src="../.gitbook/assets/my-data.gif" alt="" width="240"><figcaption><p>We get it, your data's precious.</p></figcaption></figure>
|
||||
|
||||
Ocean Protocol was built to serve the data science space. 
|
||||
### Why should data scientists use Ocean Protocol?
|
||||
|
||||
 
|
||||
Ocean Protocol is built to solve the ["Data Value Creation Loop"](the-data-value-creation-loop.md) for data scientists to **monetize data effectively**. Our [open-source tools](https://github.com/oceanprotocol) tackle some of **the biggest problems for data scientists**: how to sell data anonymously, how to sell compute jobs on datasets, how to control access to data, etc. By using blockchain architecture, Ocean achieves several tactical advantages over Web2 to solve data sharing problems.
|
||||
|
||||
With Ocean, each [Data Value Creation Loop](the-data-value-creation-loop.md) stage is tokenized with data NFTs and datatokens. Leveraging tokenized standards unlocks several unique benefits for the ecosysem. Together, stakeholders can build sophisticated products by combining assets posted onto Ocean.  
|
||||
### What are some use cases for Ocean Protocol?
|
||||
|
||||
Data engineers can publish pipelines for curated data, allowing data scientists to conduct feature engineering and build models on top. The models can be deployed with Compute-to-Data and leveraged by app developers building the last-mile distribution of model outputs into business practices.
|
||||
* Enable trustless transactions (i.e. buy, sell, transfer data)
|
||||
* Trace data provenance and consumption
|
||||
* Token gate a website or dApp using datatokens
|
||||
* Deploy a decentralized data marketplace
|
||||
* Sell algorithmic compute jobs on private datasets
|
||||
|
||||
Ocean Protocol unlocks _composable data science,_ mixing and matching assets to build end-to-end solutions. On-chain assets ensure participants can trustlessly work together while sharing the entire system's upside.
|
||||
### How to design a ML system using Ocean Protocol?
|
||||
|
||||
Explore the rest of this guide to learn more about the data value creation loop, and find your opportunity to build value with Ocean Protocol!
|
||||
The first step is to tokenize data into data NFTs and datatokens on the blockchain. We offer a no-code way to tokenize data via the [Ocean Market](https://market.oceanprotocol.com). But we also offer code options for data scientists to use the [Ocean.py](../developers/ocean.py/) and [Ocean.js](../developers/ocean.js/) libraries. Data scientists can then build sophisticated ML systems on top of the tokenized data by using composable Ocean Protocol tools. ML models can choose from a variety of Ocean smart contracts, including Ocean's [Compute-to-Data](../developers/compute-to-data/), to build model outputs all the way to the last-mile delivery for businesses.
|
||||
|
||||
### **Key Links for Data Scientists:**
|
||||
|
||||
|
||||
|
||||
|
||||
**Key Links for Data Scientists:**
|
||||
|
||||
* [Ocean data NFTs ](../developers/contracts/data-nfts.md)and [datatokens](../developers/contracts/datatokens.md) are core building blocks of Ocean Protocol. They allow individuals and businesses to define their ownership of their assets, and create flexible access control tokens
|
||||
* Ocean's [Compute-to-Data](../developers/compute-to-data/) engine resolves the trade-off between the benefits of open data and data privacy risks. Using the engine, algorithms can be run on data without exposing the underlying data. Now, data can be widely shared and monetized without 
|
||||
* [Ocean.py](../developers/ocean.py/) is our python library to interacts with Ocean contracts and tools. To get started with the library, check out our guides. They will teach installation and set-up and several popular workflows such as[ publishing an asset](../developers/ocean.py/publish-flow.md) and starting a [compute job](../developers/ocean.py/compute-flow.md).
|
||||
* Learn the difference between Ocean Protocol [data NFTs and datatokens](../developers/contracts/datanft-and-datatoken.md), the two types of tokenized data assets you need to start building your ML systems
|
||||
* Ocean's [Compute-to-Data](../developers/compute-to-data/) engine can help you to solve the difficult problem of selling algorithmic compute jobs on your datasets without actually revealing the contents of the algorithm nor dataset to the consumer
|
||||
|
||||
|
52
developers/architecture.md
Normal file
52
developers/architecture.md
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
description: Ocean Protocol Architecture Adventure!
|
||||
---
|
||||
|
||||
# Architecture Overview
|
||||
|
||||
Embark on an exploration of the innovative realm of Ocean Protocol, where data flows seamlessly and AI achieves new heights. Dive into the intricately layered architecture that converges data and services, fostering a harmonious collaboration. Let us delve deep and uncover the profound design of Ocean Protocol.🐬
|
||||
|
||||
<figure><img src="../.gitbook/assets/OP High Level Architecture.jpg" alt=""><figcaption><p>Overview of the Ocean Protocol Architecture</p></figcaption></figure>
|
||||
|
||||
### Layer 1: The Foundational Blockchain Layer
|
||||
|
||||
At the core of Ocean Protocol lies the robust [Blockchain Layer](contracts/). Powered by blockchain technology, this layer ensures secure and transparent transactions. It forms the bedrock of decentralized trust, where data providers and consumers come together to trade valuable assets. 
|
||||
|
||||
The [smart contracts](contracts/) are deployed on the Ethereum mainnet and other compatible [networks](../discover/networks/). The libraries encapsulate the calls to these smart contracts and provide features like publishing new assets, facilitating consumption, managing pricing, and much more. To explore the contracts in more depth, go ahead to the [contracts](contracts/) section.
|
||||
|
||||
### Layer 2: The Empowering Middle Layer
|
||||
|
||||
Above the smart contracts, you'll find essential [libraries](architecture.md#libraries) employed by applications within the Ocean Protocol ecosystem, the [middleware components](architecture.md#middleware-components), and [Compute-to-Data](architecture.md#compute-to-data).
|
||||
|
||||
#### Libraries
|
||||
|
||||
These libraries include [Ocean.js](broken-reference), a JavaScript library, and [Ocean.py](ocean.py/), a Python library. They serve as powerful tools for developers, enabling integration and interaction with the protocol.
|
||||
|
||||
1. [Ocean.js](broken-reference): Ocean.js is a JavaScript library that serves as a powerful tool for developers looking to integrate their applications with the Ocean Protocol ecosystem. Designed to facilitate interaction with the protocol, Ocean.js provides a comprehensive set of functionalities, including data tokenization, asset management, and smart contract interaction. Ocean.js simplifies the process of implementing data access controls, building dApps, and exploring data sets within a decentralized environment. 
|
||||
2. [Ocean.py](ocean.py/): Ocean.py is a Python library that empowers developers to integrate their applications with the Ocean Protocol ecosystem. With its rich set of functionalities, Ocean.py provides a comprehensive toolkit for interacting with the protocol. Developers and [data scientists](../data-science/) can leverage Ocean.py to perform a wide range of tasks, including data tokenization, asset management, and smart contract interactions. This library serves as a bridge between Python and the decentralized world of Ocean Protocol, enabling you to harness the power of decentralized data.
|
||||
|
||||
#### Middleware components
|
||||
|
||||
Additionally, in supporting the discovery process, middleware components come into play:
|
||||
|
||||
1. [Aquarius](aquarius/): Aquarius acts as a metadata cache, enhancing search efficiency by caching on-chain data into Elasticsearch. By accelerating metadata retrieval, Aquarius enables faster and more efficient data discovery.
|
||||
2. [Provider](provider/): The Provider component plays a crucial role in facilitating various operations within the ecosystem. It assists in asset downloading, handles [DDO](ddo-specification.md) (Decentralized Data Object) encryption, and establishes communication with the operator-service for Compute-to-Data jobs. This ensures secure and streamlined interactions between different participants.
|
||||
3. [Subgraph](subgraph/): The Subgraph is an off-chain service that utilizes GraphQL to offer efficient access to information related to datatokens, users, and balances. By leveraging the subgraph, data retrieval becomes faster compared to an on-chain query. This enhances the overall performance and responsiveness of applications that rely on accessing this information.
|
||||
|
||||
#### Compute-to-Data
|
||||
|
||||
[Compute-to-Data](compute-to-data/) (C2D) represents a groundbreaking paradigm within the Ocean Protocol ecosystem, revolutionizing the way data is processed and analyzed. With C2D, the traditional approach of moving data to the computation is inverted, ensuring privacy and security. Instead, algorithms are securely transported to the data sources, enabling computation to be performed locally, without the need to expose sensitive data. This innovative framework facilitates collaborative data analysis while preserving data privacy, making it ideal for scenarios where data owners want to retain control over their valuable assets. C2D provides a powerful tool for enabling secure and privacy-preserving data analysis and encourages collaboration among data providers, ensuring the utilization of valuable data resources while maintaining strict privacy protocols.
|
||||
|
||||
### Layer 3: The Accessible Application Layer
|
||||
|
||||
Here, the ocean comes alive with a vibrant ecosystem of dApps, marketplaces, and more. This layer hosts a variety of user-friendly interfaces, applications, and tools, inviting data scientists and curious explorers alike to access, explore, and contribute to the ocean's treasures. 
|
||||
|
||||
Prominently featured within this layer is [Ocean Market](../user-guides/using-ocean-market.md), a hub where data enthusiasts and industry stakeholders converge to discover, trade, and unlock the inherent value of data assets. Beyond Ocean Market, the Application Layer hosts a diverse ecosystem of specialized applications and marketplaces, each catering to unique use cases and industries. Empowered by the capabilities of Ocean Protocol, these applications facilitate advanced data exploration, analytics, and collaborative ventures, revolutionizing the way data is accessed, shared, and monetized. 
|
||||
|
||||
### Layer 4: The Friendly Wallets
|
||||
|
||||
At the top of the Ocean Protocol ecosystem, we find the esteemed [Web 3 Wallets](../discover/wallets/), the gateway for users to immerse themselves in the world of decentralized data transactions. These wallets serve as trusted companions, enabling users to seamlessly transact within the ecosystem, purchase and sell data NFTs, and acquire valuable datatokens. For a more detailed exploration of Web 3 Wallets and their capabilities, you can refer to the [wallet intro page](../discover/wallets/).
|
||||
|
||||
|
||||
|
||||
With the layers of the architecture clearly delineated, the stage is set for a comprehensive exploration of their underlying logic and intricate design. By examining each individually, we can gain a deeper understanding of their unique characteristics and functionalities.
|
195
developers/using-ocean-subgraph/get-data-nft-information.md
Normal file
195
developers/using-ocean-subgraph/get-data-nft-information.md
Normal file
@ -0,0 +1,195 @@
|
||||
---
|
||||
description: >-
|
||||
Explore the Power of Querying: Unveiling In-Depth Details of Individual Data
|
||||
NFTs
|
||||
---
|
||||
|
||||
# Get data NFT information
|
||||
|
||||
Now that you are familiar with the process of retrieving a list of data NFTs 😎, let's explore how to obtain more specific details about a particular NFT through querying. By utilizing the knowledge you have gained, you can customize your GraphQL query to include additional parameters such as the NFT's metadata, creator information, template, or any other relevant data points. This will enable you to delve deeper into the intricacies of a specific NFT and gain a comprehensive understanding of its attributes. With this newfound capability, you can unlock valuable insights and make informed decisions based on the specific details retrieved. So, let's dive into the fascinating world of querying and unravel the unique characteristics of individual data NFTs.
|
||||
|
||||
|
||||
|
||||
The result of the following GraphQL query returns the information about a particular data NFT. In this example, `0x1c161d721e6d99f58d47f709cdc77025056c544c`.
|
||||
|
||||
_PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](broken-reference)_._
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Javascript" %}
|
||||
The javascript below can be used to run the query and fetch the information of a data NFT. If you wish to change the network, replace the variable's value `network` as needed. Change the value of the variable `datanftAddress` with the address of your choice.
|
||||
|
||||
```runkit nodeVersion="18.x.x"
|
||||
var axios = require('axios');
|
||||
|
||||
const datanftAddress = "0x1c161d721e6d99f58d47f709cdc77025056c544c";
|
||||
|
||||
const query = `{
|
||||
nft (id:"${datanftAddress}", subgraphError:deny){
|
||||
id
|
||||
name
|
||||
symbol
|
||||
owner
|
||||
address
|
||||
assetState
|
||||
tx
|
||||
block
|
||||
transferable
|
||||
creator
|
||||
createdTimestamp
|
||||
providerUrl
|
||||
managerRole
|
||||
erc20DeployerRole
|
||||
storeUpdateRole
|
||||
metadataRole
|
||||
tokenUri
|
||||
template
|
||||
orderCount
|
||||
}
|
||||
}`
|
||||
|
||||
const network = "mainnet"
|
||||
var config = {
|
||||
method: 'post',
|
||||
url: `https://v4.subgraph.${network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: JSON.stringify({ "query": query })
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
let result = JSON.stringify(response.data)
|
||||
console.log(result)
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Python" %}
|
||||
The Python script below can be used to run the query and fetch the details about an NFT. If you wish to change the network, replace the variable's value `base_url` as needed. Change the value of the variable dataNFT\_address with the address of the datatoken of your choice.
|
||||
|
||||
**Create script**
|
||||
|
||||
{% code title="dataNFT_information.py" %}
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
dataNFT_address = "0x1c161d721e6d99f58d47f709cdc77025056c544c"
|
||||
query = """
|
||||
{{
|
||||
nft (id:"{0}", subgraphError:deny){{
|
||||
id
|
||||
name
|
||||
symbol
|
||||
owner
|
||||
address
|
||||
assetState
|
||||
tx
|
||||
block
|
||||
transferable
|
||||
creator
|
||||
createdTimestamp
|
||||
providerUrl
|
||||
managerRole
|
||||
erc20DeployerRole
|
||||
storeUpdateRole
|
||||
metadataRole
|
||||
tokenUri
|
||||
template
|
||||
orderCount
|
||||
}}
|
||||
}}""".format(
|
||||
dataNFT_address
|
||||
)
|
||||
|
||||
base_url = "https://v4.subgraph.mainnet.oceanprotocol.com"
|
||||
route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
|
||||
|
||||
url = base_url + route
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = json.dumps({"query": query})
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
result = json.loads(response.text)
|
||||
|
||||
print(json.dumps(result, indent=4, sort_keys=True))
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
**Execute script**
|
||||
|
||||
<pre class="language-bash"><code class="lang-bash"><strong>python dataNFT_information.py
|
||||
</strong></code></pre>
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Query" %}
|
||||
Copy the query to fetch the information about a data NFT in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). If you want to fetch the information about another NFT, replace the `id` with the address of your choice.
|
||||
|
||||
```graphql
|
||||
{
|
||||
nft (id:"0x1c161d721e6d99f58d47f709cdc77025056c544c", subgraphError:deny){
|
||||
id
|
||||
name
|
||||
symbol
|
||||
owner
|
||||
address
|
||||
assetState
|
||||
tx
|
||||
block
|
||||
transferable
|
||||
creator
|
||||
createdTimestamp
|
||||
providerUrl
|
||||
managerRole
|
||||
erc20DeployerRole
|
||||
storeUpdateRole
|
||||
metadataRole
|
||||
tokenUri
|
||||
template
|
||||
orderCount
|
||||
}
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Sample response</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"nft": {
|
||||
"address": "0x1c161d721e6d99f58d47f709cdc77025056c544c",
|
||||
"assetState": 0,
|
||||
"block": 15185270,
|
||||
"createdTimestamp": 1658397870,
|
||||
"creator": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"erc20DeployerRole": [
|
||||
"0x1706df1f2d93558d1d77bed49ccdb8b88fafc306"
|
||||
],
|
||||
"id": "0x1c161d721e6d99f58d47f709cdc77025056c544c",
|
||||
"managerRole": [
|
||||
"0xd30dd83132f2227f114db8b90f565bca2832afbd"
|
||||
],
|
||||
"metadataRole": null,
|
||||
"name": "Ocean Data NFT",
|
||||
"orderCount": "1",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"providerUrl": "https://v4.provider.mainnet.oceanprotocol.com",
|
||||
"storeUpdateRole": null,
|
||||
"symbol": "OCEAN-NFT",
|
||||
"template": "",
|
||||
"tokenUri": "<removed>",
|
||||
"transferable": true,
|
||||
"tx": "0x327a9da0d2e9df945fd2f8e10b1caa77acf98e803c5a2f588597172a0bcbb93a"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
238
developers/using-ocean-subgraph/get-datatoken-information.md
Normal file
238
developers/using-ocean-subgraph/get-datatoken-information.md
Normal file
@ -0,0 +1,238 @@
|
||||
---
|
||||
description: >-
|
||||
Explore the Power of Querying: Unveiling In-Depth Details of Individual
|
||||
Datatokens
|
||||
---
|
||||
|
||||
# Get datatoken information
|
||||
|
||||
To fetch detailed information about a specific datatoken, you can utilize the power of GraphQL queries. By constructing a query tailored to your needs, you can access key parameters such as the datatoken's ID, name, symbol, total supply, creator, and associated dataTokenAddress. This allows you to gain a deeper understanding of the datatoken's characteristics and properties. With this information at your disposal, you can make informed decisions, analyze market trends, and explore the vast potential of datatokens within the Ocean ecosystem. Harness the capabilities of GraphQL and unlock a wealth of datatoken insights.
|
||||
|
||||
|
||||
|
||||
The result of the following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken.
|
||||
|
||||
_PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](broken-reference)_._
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Javascript" %}
|
||||
The javascript below can be used to run the query and fetch the information of a datatoken. If you wish to change the network, replace the variable's value `network` as needed. Change the value of the variable `datatokenAddress` with the address of your choice.
|
||||
|
||||
```runkit nodeVersion="18.x.x"
|
||||
var axios = require('axios');
|
||||
|
||||
const datatokenAddress = "0x122d10d543bc600967b4db0f45f80cb1ddee43eb";
|
||||
|
||||
const query = `{
|
||||
token(id:"${datatokenAddress}", subgraphError: deny){
|
||||
id
|
||||
symbol
|
||||
nft {
|
||||
name
|
||||
symbol
|
||||
address
|
||||
}
|
||||
name
|
||||
symbol
|
||||
cap
|
||||
isDatatoken
|
||||
holderCount
|
||||
orderCount
|
||||
orders(skip:0,first:1){
|
||||
amount
|
||||
serviceIndex
|
||||
payer {
|
||||
id
|
||||
}
|
||||
consumer{
|
||||
id
|
||||
}
|
||||
estimatedUSDValue
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}
|
||||
}
|
||||
fixedRateExchanges(subgraphError:deny){
|
||||
id
|
||||
price
|
||||
active
|
||||
}
|
||||
}`
|
||||
|
||||
const network = "mainnet"
|
||||
var config = {
|
||||
method: 'post',
|
||||
url: `https://v4.subgraph.${network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: JSON.stringify({ "query": query })
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
let result = JSON.stringify(response.data)
|
||||
console.log(result);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Python" %}
|
||||
The Python script below can be used to run the query and fetch a datatoken information. If you wish to change the network, replace the variable's value `base_url` as needed. Change the value of the variable `datatoken_address` with the address of the datatoken of your choice.
|
||||
|
||||
**Create script**
|
||||
|
||||
{% code title="datatoken_information.py" %}
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
datatoken_address = "0x122d10d543bc600967b4db0f45f80cb1ddee43eb"
|
||||
query = """
|
||||
{{
|
||||
token(id:"{0}", subgraphError: deny){{
|
||||
id
|
||||
symbol
|
||||
nft {{
|
||||
name
|
||||
symbol
|
||||
address
|
||||
}}
|
||||
name
|
||||
symbol
|
||||
cap
|
||||
isDatatoken
|
||||
holderCount
|
||||
orderCount
|
||||
orders(skip:0,first:1){{
|
||||
amount
|
||||
serviceIndex
|
||||
payer {{
|
||||
id
|
||||
}}
|
||||
consumer{{
|
||||
id
|
||||
}}
|
||||
estimatedUSDValue
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}}
|
||||
}}
|
||||
fixedRateExchanges(subgraphError:deny){{
|
||||
id
|
||||
price
|
||||
active
|
||||
}}
|
||||
}}""".format(
|
||||
datatoken_address
|
||||
)
|
||||
|
||||
base_url = "https://v4.subgraph.mainnet.oceanprotocol.com/"
|
||||
route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
|
||||
|
||||
url = base_url + route
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = json.dumps({"query": query})
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
result = json.loads(response.text)
|
||||
|
||||
print(json.dumps(result, indent=4, sort_keys=True))
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
**Execute script**
|
||||
|
||||
<pre class="language-bash"><code class="lang-bash"><strong>python datatoken_information.py
|
||||
</strong></code></pre>
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Query" %}
|
||||
Copy the query to fetch the information of a datatoken in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). 
|
||||
|
||||
```
|
||||
{
|
||||
token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){
|
||||
id
|
||||
symbol
|
||||
nft {
|
||||
name
|
||||
symbol
|
||||
address
|
||||
}
|
||||
name
|
||||
symbol
|
||||
cap
|
||||
isDatatoken
|
||||
holderCount
|
||||
orderCount
|
||||
orders(skip:0,first:1){
|
||||
amount
|
||||
serviceIndex
|
||||
payer {
|
||||
id
|
||||
}
|
||||
consumer{
|
||||
id
|
||||
}
|
||||
estimatedUSDValue
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}
|
||||
}
|
||||
fixedRateExchanges(subgraphError:deny){
|
||||
id
|
||||
price
|
||||
active
|
||||
}
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Sample response</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"fixedRateExchanges": [
|
||||
{
|
||||
"active": true,
|
||||
"id": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02-0x06284c39b48afe5f01a04d56f1aae45dbb29793b190ee11e93a4a77215383d44",
|
||||
"price": "33"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"id": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02-0x2719862ebc4ed253f09088c878e00ef8ee2a792e1c5c765fac35dc18d7ef4deb",
|
||||
"price": "35"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"id": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02-0x2dccaa373e4b65d5ec153c150270e989d1bda1efd3794c851e45314c40809f9c",
|
||||
"price": "33"
|
||||
}
|
||||
],
|
||||
"token": {
|
||||
"cap": "115792089237316195423570985008687900000000000000000000000000",
|
||||
"holderCount": "0",
|
||||
"id": "0x122d10d543bc600967b4db0f45f80cb1ddee43eb",
|
||||
"isDatatoken": true,
|
||||
"name": "Brave Lobster Token",
|
||||
"nft": {
|
||||
"address": "0xea615374949a2405c3ee555053eca4d74ec4c2f0",
|
||||
"name": "Ocean Data NFT",
|
||||
"symbol": "OCEAN-NFT"
|
||||
},
|
||||
"orderCount": "0",
|
||||
"orders": [],
|
||||
"symbol": "BRALOB-11"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
250
developers/using-ocean-subgraph/list-data-nfts.md
Normal file
250
developers/using-ocean-subgraph/list-data-nfts.md
Normal file
@ -0,0 +1,250 @@
|
||||
---
|
||||
description: 'Discover the World of NFTs: Retrieving a List of Data NFTs'
|
||||
---
|
||||
|
||||
# Get data NFTs
|
||||
|
||||
If you are already familiarized with the concept of NFTs, you're off to a great start. However, if you require a refresher, we recommend visiting the [data NFTs and datatokens page](../contracts/datanft-and-datatoken.md) for a quick overview. 
|
||||
|
||||
Now, let us delve into the realm of utilizing the subgraph to extract a list of data NFTs that have been published using the Ocean contracts. By employing GraphQL queries, we can seamlessly retrieve the desired information from the subgraph. You'll see how simple it is :sunglasses:
|
||||
|
||||
You'll find below an example of a GraphQL query that retrieves the first 10 data NFTs from the subgraph. The GraphQL query is structured to access the "nfts" route, extracting the first 10 elements. For each item retrieved, it retrieves the "id," "name," "symbol," "owner," "address," "assetState," "tx," "block," and "transferable" parameters.
|
||||
|
||||
There are several options available to see this query in action. Below, you will find three:
|
||||
|
||||
1. Run the GraphQL query in the GraphiQL interface.
|
||||
2. Execute the query in Python by following the code snippet.
|
||||
3. Execute the query in JavaScript by clicking on the "Run" button of the Javascript tab.
|
||||
|
||||
_PS: In these examples, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](broken-reference)_._
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Javascript" %}
|
||||
The javascript below can be used to run the query and retrieve a list of NFTs. If you wish to change the network, then replace the value of `network` variable as needed.
|
||||
|
||||
```runkit nodeVersion="18.x.x"
|
||||
const axios = require('axios')
|
||||
|
||||
const query = `{
|
||||
nfts (skip:0, first: 10, subgraphError:deny){
|
||||
id
|
||||
name
|
||||
symbol
|
||||
owner
|
||||
address
|
||||
assetState
|
||||
tx
|
||||
block
|
||||
transferable
|
||||
}
|
||||
}`
|
||||
|
||||
const network = "mainnet"
|
||||
const config = {
|
||||
method: 'post',
|
||||
url: `https://v4.subgraph.${network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
data: JSON.stringify({ query: query })
|
||||
}
|
||||
|
||||
const response = await axios(config)
|
||||
for (let nft of response.data.data.nfts) {
|
||||
console.log(' id:' + nft.id + ' name: ' + nft.name + ' address: ' + nft.address)
|
||||
}
|
||||
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Python" %}
|
||||
The Python script below can be used to run the query to fetch a list of data NFTs from the subgraph. If you wish to change the network, replace the value of the variable `base_url` as needed.
|
||||
|
||||
**Create script**
|
||||
|
||||
{% code title="list_dataNFTs.py" %}
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
query = """
|
||||
{
|
||||
nfts (skip:0, first: 10, subgraphError:deny){
|
||||
id
|
||||
name
|
||||
symbol
|
||||
owner
|
||||
address
|
||||
assetState
|
||||
tx
|
||||
block
|
||||
transferable
|
||||
}
|
||||
}"""
|
||||
|
||||
|
||||
base_url = "https://v4.subgraph.mainnet.oceanprotocol.com"
|
||||
route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
|
||||
|
||||
url = base_url + route
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = json.dumps({"query": query})
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
result = json.loads(response.text)
|
||||
|
||||
print(json.dumps(result, indent=4, sort_keys=True))
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
**Execute script**
|
||||
|
||||
```
|
||||
python list_dataNFTs.py
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Query" %}
|
||||
Copy the query to fetch a list of data NFTs in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql).
|
||||
|
||||
```graphql
|
||||
{
|
||||
nfts (skip:0, first: 10, subgraphError:deny){
|
||||
id
|
||||
name
|
||||
symbol
|
||||
owner
|
||||
address
|
||||
assetState
|
||||
tx
|
||||
block
|
||||
transferable
|
||||
}
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Sample response</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"nfts": [
|
||||
{
|
||||
"address": "0x1c161d721e6d99f58d47f709cdc77025056c544c",
|
||||
"assetState": 0,
|
||||
"block": 15185270,
|
||||
"id": "0x1c161d721e6d99f58d47f709cdc77025056c544c",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0x327a9da0d2e9df945fd2f8e10b1caa77acf98e803c5a2f588597172a0bcbb93a"
|
||||
},
|
||||
{
|
||||
"address": "0x1e06501660623aa973474e3c59efb8ba542cb083",
|
||||
"assetState": 0,
|
||||
"block": 15185119,
|
||||
"id": "0x1e06501660623aa973474e3c59efb8ba542cb083",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0xd351ccee22b505d811c29fa524db920815936672b20b8f3a09485e389902fd27"
|
||||
},
|
||||
{
|
||||
"address": "0x2eaa55236f799c6ebec72e77a1a6296ea2e704b1",
|
||||
"assetState": 0,
|
||||
"block": 15185009,
|
||||
"id": "0x2eaa55236f799c6ebec72e77a1a6296ea2e704b1",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0xf6d55306ab4dc339dc1655a2d119af468a79a70fa62ea11de78879da61e89e7b"
|
||||
},
|
||||
{
|
||||
"address": "0x2fbe924f6c92825929dc7785fe05d15e35f2612b",
|
||||
"assetState": 0,
|
||||
"block": 15185235,
|
||||
"id": "0x2fbe924f6c92825929dc7785fe05d15e35f2612b",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0xa9ff9d461b4b7344ea181de32fa6412c7ea8e21f485ab4d8a7b9cfcdb68d9d51"
|
||||
},
|
||||
{
|
||||
"address": "0x4c04433bb1760a66be7713884bb6370e9c567cef",
|
||||
"assetState": 0,
|
||||
"block": 15185169,
|
||||
"id": "0x4c04433bb1760a66be7713884bb6370e9c567cef",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0x54c5463e8988b5fa4e4cfe71ee391505801931abe9e94bf1588dd538ec3aa4c9"
|
||||
},
|
||||
{
|
||||
"address": "0x619c500dcb0251b31cd480030db2dcc19866c0c3",
|
||||
"assetState": 0,
|
||||
"block": 15236619,
|
||||
"id": "0x619c500dcb0251b31cd480030db2dcc19866c0c3",
|
||||
"name": "abc",
|
||||
"owner": "0x12fe650c86cd4346933ef1bcab21a1979d4c6786",
|
||||
"symbol": "GOAL-9956",
|
||||
"transferable": true,
|
||||
"tx": "0x6178b03589cda98573ff52a1afbcc07b14a2fddacc0132595949e9d8a0ed1b32"
|
||||
},
|
||||
{
|
||||
"address": "0x6d45a5b38a122a6dbc042601236d6ecc5c8e343e",
|
||||
"assetState": 0,
|
||||
"block": 15109853,
|
||||
"id": "0x6d45a5b38a122a6dbc042601236d6ecc5c8e343e",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xbbd33afa85539fa65cc08a2e61a001876d2f13fe",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0x27aa77a0bf3f7878910dc7bfe2116d9271138c222b3d898381a5c72eefefe624"
|
||||
},
|
||||
{
|
||||
"address": "0x7400078c5d4fd7704afca45a928d9fc97cbea744",
|
||||
"assetState": 0,
|
||||
"block": 15185056,
|
||||
"id": "0x7400078c5d4fd7704afca45a928d9fc97cbea744",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0x2025374cd347e25e2651feec2f2faa2feb26664698eaea42b5dad1a31eda57f8"
|
||||
},
|
||||
{
|
||||
"address": "0x81decdb59dce5b4323e683a76f8fa8dd0eabc560",
|
||||
"assetState": 0,
|
||||
"block": 15185003,
|
||||
"id": "0x81decdb59dce5b4323e683a76f8fa8dd0eabc560",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0xd30dd83132f2227f114db8b90f565bca2832afbd",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0x6ad6ec2ce86bb70e077590a64c886d72975374bd2e993f143d9da8edcaace82b"
|
||||
},
|
||||
{
|
||||
"address": "0x8684119ecf77c5be41f01760ad466725ffd9b960",
|
||||
"assetState": 0,
|
||||
"block": 14933034,
|
||||
"id": "0x8684119ecf77c5be41f01760ad466725ffd9b960",
|
||||
"name": "Ocean Data NFT",
|
||||
"owner": "0x87b5606fba13529e1812319d25c6c2cd5c3f3cbc",
|
||||
"symbol": "OCEAN-NFT",
|
||||
"transferable": true,
|
||||
"tx": "0x55ba746cd8e8fb4c739b8544a9034848082b627500b854cb8db0802dd7beb172"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
213
developers/using-ocean-subgraph/list-datatokens.md
Normal file
213
developers/using-ocean-subgraph/list-datatokens.md
Normal file
@ -0,0 +1,213 @@
|
||||
---
|
||||
description: 'Discover the World of datatokens: Retrieving a List of datatokens'
|
||||
---
|
||||
|
||||
# Get datatokens
|
||||
|
||||
With your newfound knowledge of fetching data NFTs and retrieving the associated information, fetching a list of datatokens will be a breeze :ocean:. Building upon your understanding, let's now delve into the process of retrieving a list of datatokens. By applying similar techniques and leveraging the power of GraphQL queries, you'll be able to effortlessly navigate the landscape of datatokens and access the wealth of information they hold. So, let's dive right in and unlock the potential of exploring datatokens with ease and efficiency.
|
||||
|
||||
|
||||
|
||||
_PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](broken-reference)_._
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Javascript" %}
|
||||
The javascript below can be used to run the query. If you wish to change the network, replace the variable's value `network` as needed. 
|
||||
|
||||
```runkit nodeVersion="18.x.x"
|
||||
var axios = require('axios');
|
||||
|
||||
const query = `{
|
||||
tokens(skip:0, first: 2, subgraphError: deny){
|
||||
id
|
||||
symbol
|
||||
nft {
|
||||
name
|
||||
symbol
|
||||
address
|
||||
}
|
||||
name
|
||||
symbol
|
||||
cap
|
||||
isDatatoken
|
||||
holderCount
|
||||
orderCount
|
||||
orders(skip:0,first:1){
|
||||
amount
|
||||
serviceIndex
|
||||
payer {
|
||||
id
|
||||
}
|
||||
consumer{
|
||||
id
|
||||
}
|
||||
estimatedUSDValue
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
const network = "mainnet"
|
||||
var config = {
|
||||
method: 'post',
|
||||
url: `https://v4.subgraph.${network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: JSON.stringify({ "query": query })
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
let result = JSON.stringify(response.data)
|
||||
console.log(result);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Python" %}
|
||||
The Python script below can be used to run the query and fetch a list of datatokens. If you wish to change the network, then replace the value of the variable `base_url` as needed.
|
||||
|
||||
**Create script**
|
||||
|
||||
{% code title="list_all_tokens.py" %}
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
query = """
|
||||
{{
|
||||
tokens(skip:0, first: 2, subgraphError: deny){{
|
||||
id
|
||||
symbol
|
||||
nft {{
|
||||
name
|
||||
symbol
|
||||
address
|
||||
}}
|
||||
name
|
||||
symbol
|
||||
cap
|
||||
isDatatoken
|
||||
holderCount
|
||||
orderCount
|
||||
orders(skip:0,first:1){{
|
||||
amount
|
||||
serviceIndex
|
||||
payer {{
|
||||
id
|
||||
}}
|
||||
consumer{{
|
||||
id
|
||||
}}
|
||||
estimatedUSDValue
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}}
|
||||
|
||||
|
||||
}}
|
||||
}}"""
|
||||
|
||||
base_url = "https://v4.subgraph.mainnet.oceanprotocol.com"
|
||||
route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
|
||||
|
||||
url = base_url + route
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = json.dumps({"query": query})
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
result = json.loads(response.text)
|
||||
|
||||
print(json.dumps(result, indent=4, sort_keys=True))
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
**Execute script**
|
||||
|
||||
```
|
||||
python list_all_tokens.py
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Query" %}
|
||||
Copy the query to fetch a list of datatokens in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). 
|
||||
|
||||
```graphql
|
||||
{
|
||||
tokens(skip:0, first: 2, subgraphError: deny){
|
||||
id
|
||||
symbol
|
||||
nft {
|
||||
name
|
||||
symbol
|
||||
address
|
||||
}
|
||||
name
|
||||
symbol
|
||||
cap
|
||||
isDatatoken
|
||||
holderCount
|
||||
orderCount
|
||||
orders(skip:0,first:1){
|
||||
amount
|
||||
serviceIndex
|
||||
payer {
|
||||
id
|
||||
}
|
||||
consumer{
|
||||
id
|
||||
}
|
||||
estimatedUSDValue
|
||||
lastPriceToken
|
||||
lastPriceValue
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Sample Response</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"tokens": [
|
||||
{
|
||||
"cap": null,
|
||||
"holderCount": "0",
|
||||
"id": "0x0642026e7f0b6ccac5925b4e7fa61384250e1701",
|
||||
"isDatatoken": false,
|
||||
"name": "H2O",
|
||||
"nft": null,
|
||||
"orderCount": "0",
|
||||
"orders": [],
|
||||
"symbol": "H2O"
|
||||
},
|
||||
{
|
||||
"cap": "115792089237316195423570985008687900000000000000000000000000",
|
||||
"holderCount": "0",
|
||||
"id": "0x122d10d543bc600967b4db0f45f80cb1ddee43eb",
|
||||
"isDatatoken": true,
|
||||
"name": "Brave Lobster Token",
|
||||
"nft": {
|
||||
"address": "0xea615374949a2405c3ee555053eca4d74ec4c2f0",
|
||||
"name": "Ocean Data NFT",
|
||||
"symbol": "OCEAN-NFT"
|
||||
},
|
||||
"orderCount": "0",
|
||||
"orders": [],
|
||||
"symbol": "BRALOB-11"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
244
developers/using-ocean-subgraph/list-fixed-rate-exchanges.md
Normal file
244
developers/using-ocean-subgraph/list-fixed-rate-exchanges.md
Normal file
@ -0,0 +1,244 @@
|
||||
---
|
||||
description: 'Discover the World of NFTs: Retrieving a List of Fixed-rate exchanges'
|
||||
---
|
||||
|
||||
# Get fixed-rate exchanges
|
||||
|
||||
Having gained knowledge about fetching lists of data NFTs and datatokens and extracting specific information about each, let's now explore the process of retrieving the information of fixed-rate exchanges. A fixed-rate exchange refers to a mechanism where data assets can be traded at a predetermined rate or price. These exchanges offer stability and predictability in data transactions, enabling users to securely and reliably exchange data assets based on fixed rates. If you need a refresher on fixed-rate exchanges, visit the [asset pricing](../contracts/pricing-schemas.md#fixed-pricing) page.
|
||||
|
||||
|
||||
|
||||
_PS: In this example, the query is executed on the Ocean subgraph deployed on the mainnet. If you want to change the network, please refer to_ [_this table_](broken-reference)_._
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Javascript" %}
|
||||
The javascript below can be used to run the query and fetch a list of fixed-rate exchanges. If you wish to change the network, replace the variable's value `network` as needed. 
|
||||
|
||||
```runkit nodeVersion="18.x.x"
|
||||
var axios = require('axios');
|
||||
|
||||
const query = `{
|
||||
fixedRateExchanges(skip:0, first:2, subgraphError:deny){
|
||||
id
|
||||
contract
|
||||
exchangeId
|
||||
owner{id}
|
||||
datatoken{
|
||||
id
|
||||
name
|
||||
symbol
|
||||
}
|
||||
price
|
||||
datatokenBalance
|
||||
active
|
||||
totalSwapValue
|
||||
swaps(skip:0, first:1){
|
||||
tx
|
||||
by {
|
||||
id
|
||||
}
|
||||
baseTokenAmount
|
||||
dataTokenAmount
|
||||
createdTimestamp
|
||||
}
|
||||
updates(skip:0, first:1){
|
||||
oldPrice
|
||||
newPrice
|
||||
newActive
|
||||
createdTimestamp
|
||||
tx
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
const network = "mainnet"
|
||||
var config = {
|
||||
method: 'post',
|
||||
url: `https://v4.subgraph.${network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
data: JSON.stringify({ "query": query })
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
let result = JSON.stringify(response.data)
|
||||
console.log(result)
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Python" %}
|
||||
The Python script below can be used to run the query and retrieve a list of fixed-rate exchanges. If you wish to change the network, then replace the value of the variable `base_url` as needed.
|
||||
|
||||
**Create script**
|
||||
|
||||
{% code title="list_fixed_rate_exchanges.py" %}
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
query = """
|
||||
{
|
||||
fixedRateExchanges(skip:0, first:2, subgraphError:deny){
|
||||
id
|
||||
contract
|
||||
exchangeId
|
||||
owner{id}
|
||||
datatoken{
|
||||
id
|
||||
name
|
||||
symbol
|
||||
}
|
||||
price
|
||||
datatokenBalance
|
||||
active
|
||||
totalSwapValue
|
||||
swaps(skip:0, first:1){
|
||||
tx
|
||||
by {
|
||||
id
|
||||
}
|
||||
baseTokenAmount
|
||||
dataTokenAmount
|
||||
createdTimestamp
|
||||
}
|
||||
updates(skip:0, first:1){
|
||||
oldPrice
|
||||
newPrice
|
||||
newActive
|
||||
createdTimestamp
|
||||
tx
|
||||
}
|
||||
}
|
||||
}"""
|
||||
|
||||
|
||||
base_url = "https://v4.subgraph.mainnet.oceanprotocol.com"
|
||||
route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
|
||||
|
||||
url = base_url + route
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = json.dumps({"query": query})
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
result = json.loads(response.text)
|
||||
|
||||
print(json.dumps(result, indent=4, sort_keys=True))
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
**Execute script**
|
||||
|
||||
```
|
||||
python list_fixed_rate_exchanges.py
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Query" %}
|
||||
Copy the query to fetch a list of fixed-rate exchanges in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql). 
|
||||
|
||||
```
|
||||
{
|
||||
fixedRateExchanges(skip:0, first:2, subgraphError:deny){
|
||||
id
|
||||
contract
|
||||
exchangeId
|
||||
owner{id}
|
||||
datatoken{
|
||||
id
|
||||
name
|
||||
symbol
|
||||
}
|
||||
price
|
||||
datatokenBalance
|
||||
active
|
||||
totalSwapValue
|
||||
swaps(skip:0, first:1){
|
||||
tx
|
||||
by {
|
||||
id
|
||||
}
|
||||
baseTokenAmount
|
||||
dataTokenAmount
|
||||
createdTimestamp
|
||||
}
|
||||
updates(skip:0, first:1){
|
||||
oldPrice
|
||||
newPrice
|
||||
newActive
|
||||
createdTimestamp
|
||||
tx
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Sample response</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"fixedRateExchanges": [
|
||||
{
|
||||
"active": true,
|
||||
"contract": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02",
|
||||
"datatoken": {
|
||||
"id": "0x9b39a17cc72c8be4813d890172eff746470994ac",
|
||||
"name": "Delightful Pelican Token",
|
||||
"symbol": "DELPEL-79"
|
||||
},
|
||||
"datatokenBalance": "0",
|
||||
"exchangeId": "0x06284c39b48afe5f01a04d56f1aae45dbb29793b190ee11e93a4a77215383d44",
|
||||
"id": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02-0x06284c39b48afe5f01a04d56f1aae45dbb29793b190ee11e93a4a77215383d44",
|
||||
"owner": {
|
||||
"id": "0x03ef3f422d429bcbd4ee5f77da2917a699f237ed"
|
||||
},
|
||||
"price": "33",
|
||||
"swaps": [
|
||||
{
|
||||
"baseTokenAmount": "33.033",
|
||||
"by": {
|
||||
"id": "0x9b39a17cc72c8be4813d890172eff746470994ac"
|
||||
},
|
||||
"createdTimestamp": 1656563684,
|
||||
"dataTokenAmount": "1",
|
||||
"tx": "0x0b55482f69169c103563062e109f9d71afa01d18f201c425b24b1c74d3c282a3"
|
||||
}
|
||||
],
|
||||
"totalSwapValue": "0",
|
||||
"updates": []
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"contract": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02",
|
||||
"datatoken": {
|
||||
"id": "0x2cf074e36a802241f2f8ddb35f4a4557b8f1179b",
|
||||
"name": "Arcadian Eel Token",
|
||||
"symbol": "ARCEEL-17"
|
||||
},
|
||||
"datatokenBalance": "0",
|
||||
"exchangeId": "0x2719862ebc4ed253f09088c878e00ef8ee2a792e1c5c765fac35dc18d7ef4deb",
|
||||
"id": "0xfa48673a7c36a2a768f89ac1ee8c355d5c367b02-0x2719862ebc4ed253f09088c878e00ef8ee2a792e1c5c765fac35dc18d7ef4deb",
|
||||
"owner": {
|
||||
"id": "0x87b5606fba13529e1812319d25c6c2cd5c3f3cbc"
|
||||
},
|
||||
"price": "35",
|
||||
"swaps": [],
|
||||
"totalSwapValue": "0",
|
||||
"updates": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
Loading…
Reference in New Issue
Block a user