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

GITBOOK-547: Update the get datatoken buyers page

This commit is contained in:
Ana Loznianu 2023-06-19 12:20:56 +00:00 committed by gitbook-bot
parent bacfc01ac5
commit d708cb057a
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
9 changed files with 379 additions and 87 deletions

View File

@ -48,9 +48,9 @@
* [Metadata](developers/metadata.md)
* [Identifiers (DIDs)](developers/identifiers.md)
* [DDO Specification](developers/ddo-specification.md)
* [Find datatoken/data NFT addresses & Chain ID](developers/list-datatoken-buyers.md)
* [Storage Specifications](developers/storage.md)
* [Fine-Grained Permissions](developers/fg-permissions.md)
* [Retrieve datatoken/data NFT addresses & Chain ID](developers/retrieve-datatoken-address.md)
* [Barge](developers/barge/README.md)
* [Local Setup](developers/barge/local-setup-ganache.md)
* [Build a Marketplace](developers/build-a-marketplace/README.md)
@ -62,9 +62,9 @@
* [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 buyers](developers/subgraph/get-datatoken-buyers.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)
* [Install](developers/ocean.py/install.md)
* [Local Setup](developers/ocean.py/local-setup.md)

View File

@ -0,0 +1,370 @@
---
description: Query the Subgraph to see the buyers of a datatoken.
---
# Get datatoken buyers
The result of the following GraphQL query returns the list of buyers for a particular datatoken. Here, `0xc22bfd40f81c4a28c809f80d05070b95a11829d9` is the address of the datatoken.
_PS: In this example, the query is executed on the Ocean subgraph deployed on the **Mumbai** network. 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 list of buyers for a datatoken. If you wish to change the network, replace the variable's value `network` as needed. Change the value of the variable `datatoken` with the address of your choice.
```runkit nodeVersion="18.x.x"
const axios = require('axios')
const datatoken = "0xc22bfd40f81c4a28c809f80d05070b95a11829d9".toLowerCase()
const query = `{
token(id : "${datatoken}") {
id,
orders(
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
id
consumer {
id
}
payer {
id
}
reuses {
id
}
block
createdTimestamp
amount
}
}
}`
const network = "mumbai"
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) {
const orders = response.data.data.token.orders
console.log(orders)
for (let order of orders) {
console.log('id:' + order.id + ' consumer: ' + order.consumer.id + ' payer: ' + order.payer.id)
}
console.log(response.data.data.token.orders)
})
.catch(function (error) {
console.log(error);
});
```
{% endtab %}
{% tab title="Python" %}
The Python script below can be used to run the query and fetch the list of buyers for a datatoken. 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**
```python
datatoken_information.py
import requests
import json
datatoken_address = "0xc22bfd40f81c4a28c809f80d05070b95a11829d9"
query = """
{{
token(id : "${datatoken_address}") {
id,
orders(
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
id
consumer {
id
}
payer {
id
}
reuses {
id
}
block
createdTimestamp
amount
}
}
}}""".format(
datatoken_address
)
base_url = "https://v4.subgraph.mumbai.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))
```
**Execute Script**
```
python datatoken_buyers.py
```
{% endtab %}
{% tab title="Query" %}
Copy the query to fetch the list of buyers for a datatoken in the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph). 
```graphql
token(id : "0xc22bfd40f81c4a28c809f80d05070b95a11829d9") {
id,
orders(
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
id
consumer {
id
}
payer {
id
}
reuses {
id
}
block
createdTimestamp
amount
}
}
```
{% endtab %}
{% endtabs %}
<details>
<summary>Sample response</summary>
```json
{
"data": {
"token": {
"id": "0xc22bfd40f81c4a28c809f80d05070b95a11829d9",
"orders": [
{
"id": "0xd65c927af039bed60be4bfcb00a75eebe7db695598350ba9bc6cb5d6a6180062-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x0b58857708a6f84e7ee04beaef069a7e6d1d4a0b-38.0",
"consumer": {
"id": "0x0b58857708a6f84e7ee04beaef069a7e6d1d4a0b"
},
"payer": {
"id": "0x0b58857708a6f84e7ee04beaef069a7e6d1d4a0b"
},
"reuses": [],
"block": 36669814,
"createdTimestamp": 1686386048,
"amount": "1"
},
{
"id": "0x118317568256f457a6ac29ba03875ad83815d5d8ec834c721ea20d80643d8629-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x027bfbe29df80bde49845b6fecf5e4ed14518f1f-0.0",
"consumer": {
"id": "0x027bfbe29df80bde49845b6fecf5e4ed14518f1f"
},
"payer": {
"id": "0x027bfbe29df80bde49845b6fecf5e4ed14518f1f"
},
"reuses": [],
"block": 35582325,
"createdTimestamp": 1684067341,
"amount": "1"
},
{
"id": "0xe9668b60b5fe7cbfacf0311ae4dc93c50c43484c0a8cf94db783ffbee1be7cd5-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x86874bf84f0d27dcfc6c4c34ab99aad8ced8d892-1.0",
"consumer": {
"id": "0x86874bf84f0d27dcfc6c4c34ab99aad8ced8d892"
},
"payer": {
"id": "0x86874bf84f0d27dcfc6c4c34ab99aad8ced8d892"
},
"reuses": [],
"block": 35578590,
"createdTimestamp": 1684059403,
"amount": "1"
},
{
"id": "0x047a7ce1b3c69a5fc4c2c8078a2cc356164519077ef095265e4bcba1e0baf6c9-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0xb62e762af637b49eb4870bce8fe21bfff189e495-0.0",
"consumer": {
"id": "0xb62e762af637b49eb4870bce8fe21bfff189e495"
},
"payer": {
"id": "0xb62e762af637b49eb4870bce8fe21bfff189e495"
},
"reuses": [],
"block": 35511102,
"createdTimestamp": 1683915991,
"amount": "1"
},
{
"id": "0x8cbfb5a85d43f5a5b4aff4a2d657fe7dac4528a86cc78f21897fdd0169d3b3c3-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x85c1bbdc1b6a199e0964cb849deb59aef3045edd-0.0",
"consumer": {
"id": "0x85c1bbdc1b6a199e0964cb849deb59aef3045edd"
},
"payer": {
"id": "0x85c1bbdc1b6a199e0964cb849deb59aef3045edd"
},
"reuses": [],
"block": 35331127,
"createdTimestamp": 1683533500,
"amount": "1"
},
{
"id": "0x246637f9a410664c6880e7768880696763e7fd66aa7cc286fdc62d5d8589481c-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0xf9df381272afc2d1bd8fbbc0061cdb1d387c2032-3.0",
"consumer": {
"id": "0xf9df381272afc2d1bd8fbbc0061cdb1d387c2032"
},
"payer": {
"id": "0xf9df381272afc2d1bd8fbbc0061cdb1d387c2032"
},
"reuses": [],
"block": 35254580,
"createdTimestamp": 1683370838,
"amount": "1"
},
{
"id": "0xed9bcc6149cab8ee67a38d6b423a05ca328533d43ff83aff140fe9c424e449ee-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x726ab53c8da3efed40a32fe6ab5daa65b9da7ede-9.0",
"consumer": {
"id": "0x726ab53c8da3efed40a32fe6ab5daa65b9da7ede"
},
"payer": {
"id": "0x726ab53c8da3efed40a32fe6ab5daa65b9da7ede"
},
"reuses": [],
"block": 35110175,
"createdTimestamp": 1683063962,
"amount": "1"
},
{
"id": "0xa97fa2c99f8e5f16ba7245989830c552bace1f72476f5dee4da01c0d56ada7be-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x56e08babb8bf928bd8571d2a2a78235ae57ae5bd-12.0",
"consumer": {
"id": "0x56e08babb8bf928bd8571d2a2a78235ae57ae5bd"
},
"payer": {
"id": "0x56e08babb8bf928bd8571d2a2a78235ae57ae5bd"
},
"reuses": [],
"block": 35053093,
"createdTimestamp": 1682942664,
"amount": "1"
},
{
"id": "0xb9b72efad41ded4fcb7e23f14a7caa3ebc4fdfbb710318cbf25d92068c8a650d-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x56e08babb8bf928bd8571d2a2a78235ae57ae5bd-0.0",
"consumer": {
"id": "0x56e08babb8bf928bd8571d2a2a78235ae57ae5bd"
},
"payer": {
"id": "0x56e08babb8bf928bd8571d2a2a78235ae57ae5bd"
},
"reuses": [],
"block": 34985052,
"createdTimestamp": 1682798076,
"amount": "1"
},
{
"id": "0x9d616c85fdfe8655640bf77ecea0e42a7a9d331c5f51975f2a56b4f5ac8ec955-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff-0.0",
"consumer": {
"id": "0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff"
},
"payer": {
"id": "0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff"
},
"reuses": [],
"block": 34984847,
"createdTimestamp": 1682797640,
"amount": "1"
},
{
"id": "0x16eee832f9e85ca8ac8f82aecb8861e5bb5378c2771bf9abd3930b9438dbbc01-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff-9.0",
"consumer": {
"id": "0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff"
},
"payer": {
"id": "0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff"
},
"reuses": [],
"block": 34982389,
"createdTimestamp": 1682792418,
"amount": "1"
},
{
"id": "0x5264d4694fc78d9211a658363d98571f8d455dfcf89f3450520909416a103c2c-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff-0.0",
"consumer": {
"id": "0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff"
},
"payer": {
"id": "0x3f0cc2ad70839e2b684f173389f7dd71fe5186ff"
},
"reuses": [],
"block": 34980112,
"createdTimestamp": 1682787580,
"amount": "1"
},
{
"id": "0x7222faab923d80218b242aec2670c1a775c77a254a28782e04aed5cb36c395d3-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x616b5249aaf1c924339f8b8e94474e64ceb22af3-18.0",
"consumer": {
"id": "0x616b5249aaf1c924339f8b8e94474e64ceb22af3"
},
"payer": {
"id": "0x616b5249aaf1c924339f8b8e94474e64ceb22af3"
},
"reuses": [],
"block": 34969169,
"createdTimestamp": 1682764326,
"amount": "1"
},
{
"id": "0x3eae9d33fe3223e25ca058955744c98ba8aa211b1e3e1bf62eb653c0d0441b79-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x71eb23e03d3005803db491639a7ebb717810bd04-0.0",
"consumer": {
"id": "0x71eb23e03d3005803db491639a7ebb717810bd04"
},
"payer": {
"id": "0x71eb23e03d3005803db491639a7ebb717810bd04"
},
"reuses": [],
"block": 34938635,
"createdTimestamp": 1682699439,
"amount": "1"
},
{
"id": "0x8dfe458aa689a29ceea3208f55856420dbfd80ed777fd01103581cff9d7d76b7-0xc22bfd40f81c4a28c809f80d05070b95a11829d9-0x726ab53c8da3efed40a32fe6ab5daa65b9da7ede-0.0",
"consumer": {
"id": "0x726ab53c8da3efed40a32fe6ab5daa65b9da7ede"
},
"payer": {
"id": "0x726ab53c8da3efed40a32fe6ab5daa65b9da7ede"
},
"reuses": [],
"block": 34938633,
"createdTimestamp": 1682699435,
"amount": "1"
}
]
}
}
}
```
</details>

View File

@ -1,78 +0,0 @@
---
description: >-
Use these steps to reveal the information contained within an asset's DID and
list the buyers of a datatoken using the Subgraph
---
# List datatoken buyers
## Query the Subgraph to see all buyers of a datatoken
Select the corresponding subgraph URL for the asset's network. Below are some of the popular subgraph URLs, to show you the subgraph URL format.
```
https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.polygon.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.bsc.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.moonriver.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.energyweb.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.goerli.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
https://v4.subgraph.mumbai.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql?
```
You can then use the following example Javascript query to list the buyers of the datatoken.
Note, that you can also copy and paste the contents of the query function below to fetch the same info from the Ocean Subgraph [GraphiQL interface](https://v4.subgraph.mainnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph/graphql).&#x20;
```runkit nodeVersion="18.x.x"
const axios = require('axios')
const datatoken = "0xc22bfd40f81c4a28c809f80d05070b95a11829d9".toLowerCase()
const query = `{
token(id : "${datatoken}") {
id,
orders(
orderBy: createdTimestamp
orderDirection: desc
first: 1000
) {
id
consumer {
id
}
payer {
id
}
reuses {
id
}
block
createdTimestamp
amount
}
}
}`
const network = "mumbai"
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) {
const orders = response.data.data.token.orders
console.log(orders)
for (let order of orders) {
console.log('id:' + order.id + ' consumer: ' + order.consumer.id + ' payer: ' + order.payer.id)
}
console.log(response.data.data.token.orders)
})
.catch(function (error) {
console.log(error);
});
```

View File

@ -12,7 +12,7 @@ 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_](broken-reference)_._
_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" %}

View File

@ -6,13 +6,13 @@ description: >-
# 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.
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`, and `creator`. 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.&#x20;
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)_._
_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" %}
@ -80,7 +80,7 @@ axios(config)
{% 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.
The Python script below can be used to run the query and fetch the 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**

View File

@ -16,7 +16,7 @@ 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_](broken-reference)_._
_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" %}

View File

@ -8,7 +8,7 @@ With your newfound knowledge of fetching data NFTs and retrieving the associated
_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)_._
_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" %}

View File

@ -8,7 +8,7 @@ Having gained knowledge about fetching lists of data NFTs and datatokens and ext
_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)_._
_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" %}