Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Log Query Fields

Akhila Raju edited this page Jul 27, 2018 · 10 revisions

Logs can be queried from the following:

For information on each field, search the Document Explorer in the EthQL demo for the 'Log' field.

Transaction logs from 'block' root field

Fiddle with this query.

{
  block(number: 5450945) {
    transactionAt(index: 19) {
      logs {
        index
        account {
          address
        }
        topics
        data
        block {
          hash
        }
        transaction {
          hash
        }
        decoded {
          event
          entity
          standard
        }
      }
    }
  }
}

The example query above returns the following:

{
  block(number: 5450945) {
    transactionAt(index: 19) {
      logs {
        index: 12
        account {
          address: "0xA4eA687A2A7F29cF2dc66B39c68e4411C0D00C49"
        }
        topics: [
          "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
          "0x000000000000000000000000de7a1f96feb9cf24e56f93cf245ed13afed15f50",
          "0x000000000000000000000000729ae077e16366bc8a4d3fe41a742b94d73c4aa1"
        ]
        data: "0x0000000000000000000000000000000000000000000015eabf09c17f81b00000"
        block {
          hash: "0x7265fe158123e5cc8fa433c6c82e377cd62aa4efad94a1f7224770f492ca82ad"
        }
        transaction {
          hash: "0xf2554da480e4cba755c8de4dc3df5cba52af13c56239f2fd7e89fffd953b137b"
        }
        decoded {
          event: "Transfer"
          entity: "token"
          standard: "ERC20"
        }
      }
    }
  }
}

Transaction logs from 'transaction' root field

Fiddle with this query.

{
  transaction(hash: "0x7cc930cef131502bb78c13012caf0d99117892601b81fb95958aac98191fe6fb") {
    logs {
      index
      account {
        address
      }
      topics
      data
      block {
	hash
      }
      transaction {
	hash
      }
      decoded {
        event
        entity
        standard
      }
    }
  }
}

The example query above returns the following:

{
  transaction(hash: "0x7cc930cef131502bb78c13012caf0d99117892601b81fb95958aac98191fe6fb") {
      logs: [
        {
          index: 38
          account: {
            address: "0x60bf91ac87fEE5A78c28F7b67701FBCFA79C18EC"
          }
          topics: [
            "0x940c4b3549ef0aaff95807dc27f62d88ca15532d1bf535d7d63800f40395d16c",
            "0x000000000000000000000000baa705866f77af9194a8a91b8104438b20272958",
            "0x000000000000000000000000f477dc44297101ab68e7f05936d8f0810a223878",
            "0x484b4e0000000000000000000000000000000000000000000000000000000000"
          ]
          data: "0x0000000000000000000000000000000000000000000000000000001c3e0a3a88...",
          block: {
            hash: "0x7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382"
          }
          transaction: {
            hash: "0x7cc930cef131502bb78c13012caf0d99117892601b81fb95958aac98191fe6fb"
          }
          decoded: null
        },
        {
          account: {
            address: "0x9e6B2B11542f2BC52f3029077acE37E8fD838D7F"
          }
          topics: [
            "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
            "0x000000000000000000000000baa705866f77af9194a8a91b8104438b20272958",
            "0x000000000000000000000000f477dc44297101ab68e7f05936d8f0810a223878"
          ]
          data: "0x0000000000000000000000000000000000000000000000000000001c3e0a3a88"
          block: {
            hash: "0x7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382"
          }
          transaction: {
            hash: "0x7cc930cef131502bb78c13012caf0d99117892601b81fb95958aac98191fe6fb"
          }
          decoded: {
            event: "Transfer",
            entity: "token",
            standard: "ERC20"
          }
        }
      ]
    }
  }
}

ERC20 Approval Event Logs

Fiddle with this query.

{
  block(number: 5011021) {
    transactions(filter: { withInput: true }) {
      decoded {
	... on ERC20Approve {
          entity
          standard
	    operation
          from {
            account {
              address
            }
            tokenBalance
          }
          spender {
            account {
              address
            }
            tokenBalance
          }
          value
          tokenContract {
            account {
              address
            }
            symbol
            totalSupply
          }
        }
      }
    }
  }
}

The example query above returns the following:

Note: transactions under transactions(filter) were omitted to save space

{
  block(number: 5011021) {
    transactions(filter: { withInput: true }) {
            .
            .
            .
      decoded: {
        entity: "token"
        standard: "ERC20"
        operation: "approve"
        from: {
          account {
            address: "0xb97dd07CCF7520418E34Fe2d857C16C5b17bF72d"
          }
          tokenBalance: 0
        }
        spender: {
          account {
            address: "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208"
          }
          tokenBalance: 2.186866194887079e+25
        }
        value: "4.316e+22"
        tokenContract: {
          account: {
            address: "0xdA6cb58A0D0C01610a29c5A65c303e13e885887C"
          }
          symbol: "cV"
          totalSupply: 9.931143978e+27
        }
      },
            .
            .
            .
      decoded: {
        entity: "token"
        standard: "ERC20"
        operation: "approve"
        from: {
          account {
            address: "0xd4A494Ea6F54E66CEe8a631a46464B0823aDEA64"
          }
          tokenBalance: 0
        }
        spender: {
          account {
            address: "0x8d12a197cb00d4747a1fe03395095ce2a5cc6819"
          }
          tokenBalance: 2.8866106731649495e+23
        }
        value: "250000000000000000000"
        tokenContract: {
          account: {
            address: "0x9992eC3cF6A55b00978cdDF2b27BC6882d88D1eC"
          }
          symbol: "POLY"
          totalSupply: 1e+27
        }
      },
            .
            .
            .
    }
  }
}

ERC20 Transfer Event Logs

Fiddle with this query.

{
  block(number: 3100102) {
    transactions(filter: { withInput: true }) {
      decoded {
        ... on ERC20Transfer {
          entity
          standard
	  operation
          from {
            account {
              address
            }
            tokenBalance
          }
          to {
            account {
              address
            }
            tokenBalance
          }
    	  value
          tokenContract {
            account {
              address
            }
            symbol
            totalSupply
          }
        }
      }
    }
  }
}

The example query above returns the following:

Note: transactions under transactions(filter) were omitted to save space

{
  block(number: 3100102) {
    transactions(filter: { withInput: true }) {
      decoded {
        ... on ERC20Transfer {
          entity: "token"
          standard: "ERC20"
	  operation: "transfer"
          from {
            account {
              address: "0x9e0B9dDbA97Dd4f7aDdab0B5F67036EEBE687606"
            }
            tokenBalance: 5.808409295652579e+22
          }
          to {
            account {
              address: "0x60623835fcbb0cf3e909cea55009b31bb431dd28"
            }
            tokenBalance: 20018400000000000000
          }
    	  value: "1749200000000000000"
          tokenContract {
            account {
              address: "0x37a9679c41e99dB270Bda88DE8FF50c0Cd23f326"
            }
            symbol: "YOC"
            totalSupply: 3.1e+24
          }
        }
      }
    }
  }
}