1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

GITBOOK-242: Updated get datatoken information

This commit is contained in:
Ana Loznianu 2023-05-23 17:10:38 +00:00 committed by gitbook-bot
parent 1ea6904099
commit 2239ff66ca
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
5 changed files with 215 additions and 236 deletions

View File

@ -45,7 +45,7 @@
* [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 datatoken Information](developers/using-ocean-subgraph/get-datatoken-information.md)
* [List Fixed Rate Exchanges](developers/using-ocean-subgraph/list-fixed-rate-exchanges.md)
* [Ocean.py](developers/ocean.py/README.md)
* [Page 1](developers/ocean.py/page-1.md)

View File

@ -12,15 +12,19 @@ Now that you are familiar with the process of retrieving a list of 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](../ocean-subgraph/#ocean-subgraph-deployments).
_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_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %}
{% 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.
{% 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.
```graphql
{
nft (id:"0x1c161d721e6d99f58d47f709cdc77025056c544c", subgraphError:deny){
```runkit nodeVersion="18.x.x"
var axios = require('axios');
const datanftAddress = "0x1c161d721e6d99f58d47f709cdc77025056c544c";
const query = `{
nft (id:"${datanftAddress}", subgraphError:deny){
id
name
symbol
@ -41,7 +45,25 @@ Copy the query to fetch the information about a data NFT in the Ocean Subgraph [
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 %}
@ -103,16 +125,12 @@ print(json.dumps(result, indent=4, sort_keys=True))
</strong></code></pre>
{% endtab %}
{% 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.
{% 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.
```runkit nodeVersion="18.x.x"
var axios = require('axios');
const datanftAddress = "0x1c161d721e6d99f58d47f709cdc77025056c544c";
const query = `{
nft (id:"${datanftAddress}", subgraphError:deny){
```graphql
{
nft (id:"0x1c161d721e6d99f58d47f709cdc77025056c544c", subgraphError:deny){
id
name
symbol
@ -133,25 +151,7 @@ const query = `{
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 %}
{% endtabs %}

View File

@ -1,16 +1,30 @@
# Get Datatoken Information
---
description: >-
Explore the Power of Querying: Unveiling In-Depth Details of Individual
Datatokens
---
The result of following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken.
# Get datatoken Information
{% hint style="info" %}
Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](../ocean-subgraph/#ocean-subgraph-graphiql).
{% endhint %}
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.
#### Query
```graphql
{
token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){
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_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% 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 {
@ -43,14 +57,30 @@ Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprot
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 %}
#### Code
{% tabs %}
{% tab title="Python" %}
The python script below can be used to run the the query. If you wish to change the network, then replace the value of variable `base_url` as needed. Change the value of the variable `datatoken_address` with the address of the datatoken of your choice.
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**
@ -119,19 +149,10 @@ print(json.dumps(result, indent=4, sort_keys=True))
</strong></code></pre>
{% endtab %}
{% tab title="Javascript" %}
The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed. Change the value of the variable `datatokenAddress` with the address of the datatoken of your choice.
**Create script**
{% code title="datatokenInfo.js" %}
```javascript
var axios = require('axios');
const datatokenAddress = "0x122d10d543bc600967b4db0f45f80cb1ddee43eb";
const query = `{
token(id:"${datatokenAddress}", subgraphError: deny){
{% tab title="Query" %}
```
{
token(id:"0x122d10d543bc600967b4db0f45f80cb1ddee43eb", subgraphError: deny){
id
symbol
nft {
@ -164,35 +185,7 @@ const query = `{
price
active
}
}`
const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com"
const route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
const url = `${baseUrl}${route}`
var config = {
method: 'post',
url: url,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ "query": query })
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
```
{% endcode %}
**Execute script**
```bash
node datatokenInfo.js
}
```
{% endtab %}
{% endtabs %}

View File

@ -16,26 +16,42 @@ There are several options available to see this query in action. Below, you will
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](../ocean-subgraph/#ocean-subgraph-deployments).
_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_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %}
{% 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).
{% 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.
```graphql
{
nfts (skip:0, first: 10, subgraphError:degraphny){
id
name
symbol
owner
address
assetState
tx
block
transferable
}
```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 %}
@ -87,39 +103,23 @@ python list_dataNFTs.py
```
{% endtab %}
{% 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.
{% 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).
```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 })
```graphql
{
nfts (skip:0, first: 10, subgraphError:degraphny){
id
name
symbol
owner
address
assetState
tx
block
transferable
}
}
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 %}
{% endtabs %}

View File

@ -4,54 +4,72 @@ description: 'Discover the World of datatokens: Retrieving a List of datatokens'
# Get datatokens
The result of following GraphQL query returns the information about 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.
{% hint style="info" %}
Copy the query in the [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql) to fetch the results from the mainnet. For other networks use [this table](../ocean-subgraph/#ocean-subgraph-graphiql).
{% endhint %}
#### Query
#### Code
_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_](../ocean-subgraph/#ocean-subgraph-deployments)_._
{% tabs %}
{% tab title="Query" %}
```graphql
{
tokens(skip:0, first: 2, subgraphError: deny){
id
symbol
nft {
{% 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.&#x20;
```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
address
}
name
symbol
cap
isDatatoken
holderCount
orderCount
orders(skip:0,first:1){
amount
serviceIndex
payer {
id
cap
isDatatoken
holderCount
orderCount
orders(skip:0,first:1){
amount
serviceIndex
payer {
id
}
consumer{
id
}
estimatedUSDValue
lastPriceToken
lastPriceValue
}
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 the query. If you wish to change the network, then replace the value of variable `base_url` as needed.
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**
@ -115,72 +133,40 @@ python list_all_tokens.py
```
{% endtab %}
{% tab title="Javascript" %}
The javascript below can be used to run the the query. If you wish to change the network, then replace the value of variable `baseUrl` as needed.
{% 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).&#x20;
**Create script**
{% code title="listAllTokens.js" %}
```javascript
var axios = require('axios');
const query = `{
tokens(skip:0, first: 2, subgraphError: deny){
id
symbol
nft {
name
symbol
address
}
```graphql
{
tokens(skip:0, first: 2, subgraphError: deny){
id
symbol
nft {
name
symbol
cap
isDatatoken
holderCount
orderCount
orders(skip:0,first:1){
amount
serviceIndex
payer {
id
}
consumer{
id
}
estimatedUSDValue
lastPriceToken
lastPriceValue
}
address
}
}`
const baseUrl = "https://v4.subgraph.mainnet.oceanprotocol.com"
const route = "/subgraphs/name/oceanprotocol/ocean-subgraph"
const url = `${baseUrl}${route}`
var config = {
method: 'post',
url: url,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ "query": query })
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
```
{% endcode %}
**Execute script**
```bash
node listAllTokens.js
name
symbol
cap
isDatatoken
holderCount
orderCount
orders(skip:0,first:1){
amount
serviceIndex
payer {
id
}
consumer{
id
}
estimatedUSDValue
lastPriceToken
lastPriceValue
}
}
}
```
{% endtab %}
{% endtabs %}