Query

mail@pastecode.io avatar
unknown
javascript
a year ago
1.4 kB
4
Indexable
Never
const fetchTransfers = async () => {
  try {
    const myHeaders = new Headers();
    myHeaders.append("Content-Type", "application/json");
    myHeaders.append("X-API-KEY", "             ");

    const raw = JSON.stringify({
      query: `query {
        ethereum(network: bsc) {
          transfers(
            options: { desc: "amount", limit: 100 }
            sender: { is: "0xee63b115ac551fe6184bee4f383eccfbaa922bf9" }
            receiver: { is: "0x0000000000000000000000000000000000000000" }
            currency: { is: "0x6d6768a0b24299bede0492a4571d79f535c330d8" }
          ) {
            transaction {
              hash
            }
            sender {
              address
            }
            receiver {
              address
            }
            currency {
              address
              symbol
            }
            amount
            external
          }
        }
      }`,
      variables: "{}",
    });

    const requestOptions = {
      method: "POST",
      headers: myHeaders,
      body: raw,
      redirect: "follow",
    };

    const response = await fetch("https://graphql.bitquery.io", requestOptions);
    const result = await response.text();
    console.log(result);
  } catch (error) {
    console.log("Error:", error);
  }
};

fetchTransfers();