Skip to content

Instantly share code, notes, and snippets.

@ries9112
Created June 29, 2021 11:53
Show Gist options
  • Save ries9112/e1734d6fb30030e5d81a430d338e86e8 to your computer and use it in GitHub Desktop.
Save ries9112/e1734d6fb30030e5d81a430d338e86e8 to your computer and use it in GitHub Desktop.
CV pull data using TheGraph
// 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