Looping in a Grapgql Query

Hi, I am trying to run a query getting mint info on a smartcontract. I have a number of smart contract addresses that I want to run and was wondering how I could do that in a loop rather than manually changing the address shown below as ā€œ0xb4e16d0168e52d35cacd2c6185b44281ec28c9dcā€. Thanks

query MyQuery {
  ethereum {
    smartContractEvents(
      smartContractAddress: {is: "0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc"}
      smartContractEvent: {is: "Mint"}
      options: {limit: 16931, desc: "block.height"}
    ) {
      block {
        height
      }
      arguments {
        value
        argument
      }
      smartContract {
        currency {
          symbol
        }
      }
    }
  }
}

Welcome to the community @Ben_Mcdermott

Where are all the addresses you want to check?

You can get them from wherever they are and then use expressions to reference them in the query.

1 Like

Thanks for the reply! I have them saved on a csv file from a previous query that got me all the pair addresses. I am currently using python and am very new. Will I be able to loop the csv so they run in the query one at a time?

Yes, n8n will automatically iterate over all items on the csv. You need to read the csv using the Spreadsheet File node. You can also upload the csv to Google Drive (or similar tool), download it using the Google Drive node and then use to Speadsheet File to read it.

2 Likes

Great! Thank you for the help

1 Like