mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Subgraph examples (#1085)
* GitBook: [#1] No subject * GitBook: [#2] No subject * GitBook: [#3] No subject * GitBook: [#4] No subject * GitBook: [#5] No subject * GitBook: [#6] Subgraph examples * GitBook: [#7] Subgraph examples * GitBook: [#8] Add hint for GraphQL interface
This commit is contained in:
parent
a47b119007
commit
3c32812292
@ -36,6 +36,12 @@
|
|||||||
* [Deploying Aquarius](building-with-ocean/deploying-components/deploying-aquarius.md)
|
* [Deploying Aquarius](building-with-ocean/deploying-components/deploying-aquarius.md)
|
||||||
* [Deploying Provider](building-with-ocean/deploying-components/deploying-provider.md)
|
* [Deploying Provider](building-with-ocean/deploying-components/deploying-provider.md)
|
||||||
* [Deploying Ocean subgraph](building-with-ocean/deploying-components/deploying-ocean-subgraph.md)
|
* [Deploying Ocean subgraph](building-with-ocean/deploying-components/deploying-ocean-subgraph.md)
|
||||||
|
* [Using Ocean Subgraph](building-with-ocean/using-ocean-subgraph/README.md)
|
||||||
|
* [List data NFTs](building-with-ocean/using-ocean-subgraph/list-data-nfts.md)
|
||||||
|
* [List all tokens](building-with-ocean/using-ocean-subgraph/list-datatokens.md)
|
||||||
|
* [Get data NFT information](building-with-ocean/using-ocean-subgraph/get-data-nft-information.md)
|
||||||
|
* [Get datatoken information](building-with-ocean/using-ocean-subgraph/get-datatoken-information.md)
|
||||||
|
* [List Fixed Rate Exchanges](building-with-ocean/using-ocean-subgraph/list-fixed-rate-exchanges.md)
|
||||||
* [Contributing](core-concepts/contributing.md)
|
* [Contributing](core-concepts/contributing.md)
|
||||||
* [Contributor Code of Conduct](core-concepts/code-of-conduct.md)
|
* [Contributor Code of Conduct](core-concepts/code-of-conduct.md)
|
||||||
* [Legal Requirements](core-concepts/legal-reqs.md)
|
* [Legal Requirements](core-concepts/legal-reqs.md)
|
||||||
|
10
building-with-ocean/using-ocean-subgraph/README.md
Normal file
10
building-with-ocean/using-ocean-subgraph/README.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
description: >-
|
||||||
|
Ocean subgraph is an off-chain service which provides information about
|
||||||
|
datatokens, users, balances using the GraphQL. Ocean subgraph provides a
|
||||||
|
faster way to fetch data rather than on-chain query.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Using Ocean Subgraph
|
||||||
|
|
||||||
|
For each supported network, an individual Ocean subgraph is deployed. The information about supported networks and the subgraph URL is available on [this page](../../core-concepts/networks.md).
|
@ -0,0 +1,130 @@
|
|||||||
|
# Get data NFT information
|
||||||
|
|
||||||
|
The result of following GraphQL query returns the information about a particular datatoken. Here, `0x1c161d721e6d99f58d47f709cdc77025056c544c` is the address of the dataNFT.  
|
||||||
|
|
||||||
|
{% 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, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md).
|
||||||
|
{% endhint %}
|
||||||
|
|
||||||
|
```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
|
||||||
|
}
|
||||||
|
}b
|
||||||
|
```
|
||||||
|
|
||||||
|
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 dataNFT\_address with the address of the datatoken of your choice.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab title="Python" %}
|
||||||
|
{% 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
|
||||||
|
|
||||||
|
```
|
||||||
|
python dataNFT_information.py
|
||||||
|
```
|
||||||
|
{% 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>
|
@ -0,0 +1,166 @@
|
|||||||
|
# Get datatoken information
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The result of following GraphQL query returns the information about a particular datatoken. Here, `0x122d10d543bc600967b4db0f45f80cb1ddee43eb` is the address of the datatoken.  
|
||||||
|
|
||||||
|
{% 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, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md).
|
||||||
|
{% endhint %}
|
||||||
|
|
||||||
|
```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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab title="Python" %}
|
||||||
|
#### 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
|
||||||
|
|
||||||
|
```
|
||||||
|
python datatoken_information.py
|
||||||
|
```
|
||||||
|
{% 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>
|
196
building-with-ocean/using-ocean-subgraph/list-data-nfts.md
Normal file
196
building-with-ocean/using-ocean-subgraph/list-data-nfts.md
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
# List data NFTs
|
||||||
|
|
||||||
|
The result of following GraphQL query returns the information about data nfts. 
|
||||||
|
|
||||||
|
{% 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, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md).
|
||||||
|
{% endhint %}
|
||||||
|
|
||||||
|
```graphql
|
||||||
|
{
|
||||||
|
nfts (skip:0, first: 10, subgraphError:deny){
|
||||||
|
id
|
||||||
|
name
|
||||||
|
symbol
|
||||||
|
owner
|
||||||
|
address
|
||||||
|
assetState
|
||||||
|
tx
|
||||||
|
block
|
||||||
|
transferable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab title="Python" %}
|
||||||
|
{% 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 %}
|
||||||
|
{% 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>
|
150
building-with-ocean/using-ocean-subgraph/list-datatokens.md
Normal file
150
building-with-ocean/using-ocean-subgraph/list-datatokens.md
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
# List all tokens
|
||||||
|
|
||||||
|
The result of following GraphQL query returns the information about datatokens.  
|
||||||
|
|
||||||
|
{% 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, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md).
|
||||||
|
{% endhint %}
|
||||||
|
|
||||||
|
```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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab title="Python" %}
|
||||||
|
#### 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 %}
|
||||||
|
{% 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>
|
||||||
|
|
@ -0,0 +1,176 @@
|
|||||||
|
# List Fixed Rate Exchanges
|
||||||
|
|
||||||
|
The result of following GraphQL query returns the information about the Fixed Rate Exchanges.  
|
||||||
|
|
||||||
|
{% 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, change the domain name with appropriate subgraph domain as mentioned in [this page](../../core-concepts/networks.md).
|
||||||
|
{% endhint %}
|
||||||
|
|
||||||
|
```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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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. 
|
||||||
|
|
||||||
|
{% tabs %}
|
||||||
|
{% tab title="Python" %}
|
||||||
|
#### 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 %}
|
||||||
|
{% 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