Created
June 29, 2021 11:53
-
-
Save ries9112/e1734d6fb30030e5d81a430d338e86e8 to your computer and use it in GitHub Desktop.
CV pull data using TheGraph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add script to a button inside Cryptovoxels to return a response | |
feature.on('click',e=>{ | |
// Use GraphQL endpoint to pull data and make model that takes x,y Decentraland coordinates and returns prediction based on the latest 10 sales! | |
fetch('https://api.thegraph.com/subgraphs/name/decentraland/marketplace', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
query: ` | |
query example { | |
orders(where: {status: "sold"}, first: 10, orderBy: createdAt, orderDirection: desc){ | |
id | |
price | |
buyer | |
status | |
createdAt | |
updatedAt | |
txHash | |
nft{ | |
id | |
tokenId | |
contractAddress | |
tokenURI | |
name | |
image | |
searchParcelX | |
searchParcelY | |
} | |
} | |
} | |
`, | |
}), | |
}) | |
.then((res) => res.json()) | |
.then((result) => { | |
// do stuff here | |
console.log(result); | |
console.log(result.data.orders[0].buyer) | |
console.log(result.data.orders[0].price) | |
console.log(result.data.orders[0].status) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment