Hi,
I try to get newly created Ethereum contracts. The query is working. But using node js, I found no solution to go through the json reponse array. My goal is to just extract the ERC20 token addresses. If I do the response in text format - await response.text() -, I see that the reponse is OK, but I found no way to loop through the json response to extract my needed information. Afterwords the complete code. Any hints would be great. Thanks!
const fetch = require(‘node-fetch’)
const query = { ethereum { smartContractCalls( options: {desc: "block.height", limit: 10} smartContractMethod: {is: "Contract Creation"} smartContractType: {is: Token} ) { block { height timestamp { time } } smartContract { contractType address { address annotation } currency { name symbol decimals tokenType } } } } }
;
const url = “https://graphql.bitquery.io/”;
const test = async () => {
const response = await fetch(url, {
method: “POST”,
headers: {
“Content-Type”: “application/json”,
“X-API-KEY”: “MyAPIKEY”
},
body: JSON.stringify({
query
})
})
const data = await response.json();
console.log (data)
}
test()
======
Output is:
{ data: { ethereum: { smartContractCalls: [Array] } } }